@Test public void latestValidTimeOrNewOf1() { Time time1 = newTime(Instant.ofEpochSecond(12340000, 0)); Time time2 = newTime(Instant.ofEpochSecond(12340000, 0)); Time time3 = newTime(Instant.ofEpochSecond(12350000, 0)); Time time4 = newTime(Instant.ofEpochSecond(12360000, 0)); Time time5 = newTime(Instant.ofEpochSecond(12370000, 0), 1, false); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(time1, time3)), sameInstance(time3)); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(time3, time1)), sameInstance(time3)); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(time1, time2)), sameInstance(time1)); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(time2, time1)), sameInstance(time2)); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(time1, time4, time5, time3)), sameInstance(time4)); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(time5)), not(sameInstance(time5))); assertThat(ValueUtil.latestValidTimeOrNowOf(Arrays.<Object>asList(null, null)), not(nullValue())); }
public static Time latestValidTimeOrNowOf(final List<Object> args) { Time finalTime = null; for (Object object : args) { Time newTime; if (object != null) { newTime = ValueUtil.timeOf(object); if (newTime != null && newTime.isTimeValid() && (finalTime == null || newTime.getTimestamp().compareTo(finalTime.getTimestamp()) > 0)) { finalTime = newTime; } } } if (finalTime == null) { finalTime = ValueFactory.timeNow(); } return finalTime; }
ValueUtil { public static Time latestValidTimeOrNowOf(final List<Object> args) { Time finalTime = null; for (Object object : args) { Time newTime; if (object != null) { newTime = ValueUtil.timeOf(object); if (newTime != null && newTime.isTimeValid() && (finalTime == null || newTime.getTimestamp().compareTo(finalTime.getTimestamp()) > 0)) { finalTime = newTime; } } } if (finalTime == null) { finalTime = ValueFactory.timeNow(); } return finalTime; } }
ValueUtil { public static Time latestValidTimeOrNowOf(final List<Object> args) { Time finalTime = null; for (Object object : args) { Time newTime; if (object != null) { newTime = ValueUtil.timeOf(object); if (newTime != null && newTime.isTimeValid() && (finalTime == null || newTime.getTimestamp().compareTo(finalTime.getTimestamp()) > 0)) { finalTime = newTime; } } } if (finalTime == null) { finalTime = ValueFactory.timeNow(); } return finalTime; } private  ValueUtil(); }
ValueUtil { public static Time latestValidTimeOrNowOf(final List<Object> args) { Time finalTime = null; for (Object object : args) { Time newTime; if (object != null) { newTime = ValueUtil.timeOf(object); if (newTime != null && newTime.isTimeValid() && (finalTime == null || newTime.getTimestamp().compareTo(finalTime.getTimestamp()) > 0)) { finalTime = newTime; } } } if (finalTime == null) { finalTime = ValueFactory.timeNow(); } return finalTime; } private  ValueUtil(); static Class<?> typeOf(Object obj); static Alarm alarmOf(Object obj); static Alarm alarmOf(Object value, boolean connected); static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull); static Time latestTimeOf(final List<Object> args); static Time latestValidTimeOrNowOf(final List<Object> args); static Time timeOf(Object obj); static Display displayOf(Object obj); static boolean displayHasValidDisplayLimits(Display display); static Double normalizedNumericValueOf(Object obj); static Double normalize(Number value, Display display); static Double normalize(Number value, Number lowValue, Number highValue); static Double numericValueOf(Object obj); static BufferedImage toImage(VImage vImage); static VImage toVImage(BufferedImage image); static boolean displayEquals(Display d1, Display d2); static void setAlarmSeverityColorMap(Map<AlarmSeverity, Integer> map); static int colorFor(AlarmSeverity severity); static DateTimeFormatter getDefaultTimestampFormat(); static void setDefaultTimestampFormat(DateTimeFormatter defaultTimestampFormat); static NumberFormat getDefaultNumberFormat(); static void setDefaultNumberFormat(NumberFormat defaultNumberFormat); static ValueFormat getDefaultValueFormat(); static void setDefaultValueFormat(ValueFormat defaultValueFormat); static ListNumber numericColumnOf(VTable table, String columnName); static List<String> stringColumnOf(VTable table, String columnName); static List<ArrayDimensionDisplay> defaultArrayDisplay(VNumberArray array); static List<ArrayDimensionDisplay> defaultArrayDisplay(ListInt sizes); static VNumberArray subArray(VNumberArray array, int index); }
ValueUtil { public static Time latestValidTimeOrNowOf(final List<Object> args) { Time finalTime = null; for (Object object : args) { Time newTime; if (object != null) { newTime = ValueUtil.timeOf(object); if (newTime != null && newTime.isTimeValid() && (finalTime == null || newTime.getTimestamp().compareTo(finalTime.getTimestamp()) > 0)) { finalTime = newTime; } } } if (finalTime == null) { finalTime = ValueFactory.timeNow(); } return finalTime; } private  ValueUtil(); static Class<?> typeOf(Object obj); static Alarm alarmOf(Object obj); static Alarm alarmOf(Object value, boolean connected); static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull); static Time latestTimeOf(final List<Object> args); static Time latestValidTimeOrNowOf(final List<Object> args); static Time timeOf(Object obj); static Display displayOf(Object obj); static boolean displayHasValidDisplayLimits(Display display); static Double normalizedNumericValueOf(Object obj); static Double normalize(Number value, Display display); static Double normalize(Number value, Number lowValue, Number highValue); static Double numericValueOf(Object obj); static BufferedImage toImage(VImage vImage); static VImage toVImage(BufferedImage image); static boolean displayEquals(Display d1, Display d2); static void setAlarmSeverityColorMap(Map<AlarmSeverity, Integer> map); static int colorFor(AlarmSeverity severity); static DateTimeFormatter getDefaultTimestampFormat(); static void setDefaultTimestampFormat(DateTimeFormatter defaultTimestampFormat); static NumberFormat getDefaultNumberFormat(); static void setDefaultNumberFormat(NumberFormat defaultNumberFormat); static ValueFormat getDefaultValueFormat(); static void setDefaultValueFormat(ValueFormat defaultValueFormat); static ListNumber numericColumnOf(VTable table, String columnName); static List<String> stringColumnOf(VTable table, String columnName); static List<ArrayDimensionDisplay> defaultArrayDisplay(VNumberArray array); static List<ArrayDimensionDisplay> defaultArrayDisplay(ListInt sizes); static VNumberArray subArray(VNumberArray array, int index);  }