@Test public void highestSeverityOf1() { Alarm none = ValueFactory.alarmNone(); Alarm minor = ValueFactory.newAlarm(AlarmSeverity.MINOR, "Minor alarm"); Alarm otherMinor = ValueFactory.newAlarm(AlarmSeverity.MINOR, "Other minor alarm"); Alarm major = ValueFactory.newAlarm(AlarmSeverity.MAJOR, "Major alarm"); Alarm invalid = ValueFactory.newAlarm(AlarmSeverity.INVALID, "Invalid alarm"); Alarm undefined = ValueFactory.newAlarm(AlarmSeverity.UNDEFINED, "Undefined alarm"); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(none, minor), false), sameInstance(minor)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(none, minor, otherMinor), false), sameInstance(minor)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(null, minor, otherMinor), false), sameInstance(minor)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(null, minor, otherMinor), true).getAlarmSeverity(), sameInstance(AlarmSeverity.UNDEFINED)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(none, major, minor, otherMinor), false), sameInstance(major)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(none, major, minor, otherMinor, invalid), false), sameInstance(invalid)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(none, major, minor, undefined, invalid), false), sameInstance(undefined)); assertThat(ValueUtil.highestSeverityOf(Arrays.<Object>asList(none, major, minor, undefined, invalid, null), true), sameInstance(undefined)); }
public static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull) { Alarm finalAlarm = ValueFactory.alarmNone(); for (Object object : args) { Alarm newAlarm; if (object == null && considerNull) { newAlarm = ValueFactory.newAlarm(AlarmSeverity.UNDEFINED, "No Value"); } else { newAlarm = ValueUtil.alarmOf(object); if (newAlarm == null) { newAlarm = ValueFactory.alarmNone(); } } if (newAlarm.getAlarmSeverity().compareTo(finalAlarm.getAlarmSeverity()) > 0) { finalAlarm = newAlarm; } } return finalAlarm; }
ValueUtil { public static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull) { Alarm finalAlarm = ValueFactory.alarmNone(); for (Object object : args) { Alarm newAlarm; if (object == null && considerNull) { newAlarm = ValueFactory.newAlarm(AlarmSeverity.UNDEFINED, "No Value"); } else { newAlarm = ValueUtil.alarmOf(object); if (newAlarm == null) { newAlarm = ValueFactory.alarmNone(); } } if (newAlarm.getAlarmSeverity().compareTo(finalAlarm.getAlarmSeverity()) > 0) { finalAlarm = newAlarm; } } return finalAlarm; } }
ValueUtil { public static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull) { Alarm finalAlarm = ValueFactory.alarmNone(); for (Object object : args) { Alarm newAlarm; if (object == null && considerNull) { newAlarm = ValueFactory.newAlarm(AlarmSeverity.UNDEFINED, "No Value"); } else { newAlarm = ValueUtil.alarmOf(object); if (newAlarm == null) { newAlarm = ValueFactory.alarmNone(); } } if (newAlarm.getAlarmSeverity().compareTo(finalAlarm.getAlarmSeverity()) > 0) { finalAlarm = newAlarm; } } return finalAlarm; } private  ValueUtil(); }
ValueUtil { public static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull) { Alarm finalAlarm = ValueFactory.alarmNone(); for (Object object : args) { Alarm newAlarm; if (object == null && considerNull) { newAlarm = ValueFactory.newAlarm(AlarmSeverity.UNDEFINED, "No Value"); } else { newAlarm = ValueUtil.alarmOf(object); if (newAlarm == null) { newAlarm = ValueFactory.alarmNone(); } } if (newAlarm.getAlarmSeverity().compareTo(finalAlarm.getAlarmSeverity()) > 0) { finalAlarm = newAlarm; } } return finalAlarm; } 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 Alarm highestSeverityOf(final List<Object> args, final boolean considerNull) { Alarm finalAlarm = ValueFactory.alarmNone(); for (Object object : args) { Alarm newAlarm; if (object == null && considerNull) { newAlarm = ValueFactory.newAlarm(AlarmSeverity.UNDEFINED, "No Value"); } else { newAlarm = ValueUtil.alarmOf(object); if (newAlarm == null) { newAlarm = ValueFactory.alarmNone(); } } if (newAlarm.getAlarmSeverity().compareTo(finalAlarm.getAlarmSeverity()) > 0) { finalAlarm = newAlarm; } } return finalAlarm; } 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);  }