And all the changes required for this to work.
Change-Id: Ie07326346cf187f37011d5c624665186440f4517
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/90189
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
import java.text.ParsePosition;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.tmf.chart.ui.data.ChartRangeMap;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
* @return the pattern string.
*/
public String getPattern() {
- return NonNullUtils.checkNotNull(fFormat.toPattern());
+ return fFormat.toPattern();
}
// ------------------------------------------------------------------------
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.tmf.core.Activator;
/**
*
* @return the timestamp pattern
*/
- public static String getTimePattern() {
+ public static @NonNull String getTimePattern() {
return computeTimePattern(getPreferenceMap(false));
}
*
* @return the interval pattern
*/
- public static String getIntervalPattern() {
+ public static @NonNull String getIntervalPattern() {
return computeIntervalPattern(getPreferenceMap(false));
}
// Operations
// ------------------------------------------------------------------------
- private static String computeIntervalPattern(Map<String, String> prefsMap) {
+ private static @NonNull String computeIntervalPattern(Map<String, String> prefsMap) {
String ssecFmt = computeSubSecFormat(prefsMap);
return ITmfTimePreferencesConstants.TIME_ELAPSED_FMT + "." + ssecFmt; //$NON-NLS-1$
}
* @param prefsMap the preferences to apply when computing the time pattern
* @return the time pattern resulting in applying the preferences
*/
- public static String computeTimePattern(Map<String, String> prefsMap) {
+ public static @NonNull String computeTimePattern(Map<String, String> prefsMap) {
String dateTimeFormat = prefsMap.get(ITmfTimePreferencesConstants.DATIME);
if (dateTimeFormat == null) {
dateTimeFormat = ITmfTimePreferencesConstants.DEFAULT_TIME_PATTERN;
import java.util.Map;
import java.util.TimeZone;
+import org.eclipse.jdt.annotation.NonNull;
+
/**
* A formatting and parsing facility that can handle timestamps that span the
* epoch with a precision down to the nanosecond. It can be understood as an
private static TmfTimestampFormat fDefaultIntervalFormat = null;
// The timestamp pattern
- private String fPattern;
+ private @NonNull String fPattern;
// The index of the decimal separator in the pattern
private int fPatternDecimalSeparatorIndex;
*
* @param pattern the format pattern
*/
- public TmfTimestampFormat(String pattern) {
+ public TmfTimestampFormat(@NonNull String pattern) {
fLocale = Locale.getDefault();
+ fPattern = pattern;
applyPattern(pattern);
}
* @param pattern the format pattern
* @param timeZone the time zone
*/
- public TmfTimestampFormat(String pattern, TimeZone timeZone) {
+ public TmfTimestampFormat(@NonNull String pattern, TimeZone timeZone) {
fLocale = Locale.getDefault();
setTimeZone(timeZone);
+ fPattern = pattern;
applyPattern(pattern);
}
* @param timeZone the time zone
* @param locale the locale
*/
- public TmfTimestampFormat(String pattern, TimeZone timeZone, Locale locale) {
+ public TmfTimestampFormat(@NonNull String pattern, TimeZone timeZone, Locale locale) {
super("", locale); //$NON-NLS-1$
fLocale = locale;
setTimeZone(timeZone);
setCalendar(Calendar.getInstance(timeZone, locale));
+ fPattern = pattern;
applyPattern(pattern);
}
@Override
public void applyPattern(String pattern) {
+ if (pattern == null) {
+ throw new NullPointerException("TmfTimestampFormat: pattern should not be null"); //$NON-NLS-1$
+ }
fPattern = pattern;
fPatternDecimalSeparatorIndex = indexOfPatternDecimalSeparator(pattern);
fDateTimePattern = unquotePattern(pattern.substring(0, fPatternDecimalSeparatorIndex));
}
@Override
- public String toPattern() {
+ public @NonNull String toPattern() {
return fPattern;
}