@Test public void numericValueOf1() { assertThat(numericValueOf(newVDouble(1.0)), equalTo(1.0)); assertThat(numericValueOf(newVInt(1, alarmNone(), timeNow(), displayNone())), equalTo(1.0)); assertThat(numericValueOf(newVEnum(1, Arrays.asList("ONE", "TWO", "THREE"), alarmNone(), timeNow())), equalTo(1.0)); assertThat(numericValueOf(newVDoubleArray(new ArrayDouble(1.0), alarmNone(), timeNow(), displayNone())), equalTo(1.0)); assertThat(numericValueOf(newVFloatArray(new ArrayFloat(1.0f), alarmNone(), timeNow(), displayNone())), equalTo(1.0)); assertThat(numericValueOf(newVIntArray(new ArrayInt(1), alarmNone(), timeNow(), displayNone())), equalTo(1.0)); assertThat(numericValueOf(newVEnumArray(new ArrayInt(1,0,2), Arrays.asList("ONE", "TWO", "THREE"), alarmNone(), timeNow())), equalTo(1.0)); }
public static Double numericValueOf(Object obj) { if (obj instanceof VNumber) { Number value = ((VNumber) obj).getValue(); if (value != null) { return value.doubleValue(); } } if (obj instanceof VBoolean) { return (double) (((VBoolean) obj).getValue() ? 1 : 0); } if (obj instanceof VEnum) { return (double) ((VEnum) obj).getIndex(); } if (obj instanceof VNumberArray) { ListNumber data = ((VNumberArray) obj).getData(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof VEnumArray) { ListNumber data = ((VEnumArray) obj).getIndexes(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof MultiScalar) { List values = ((MultiScalar) obj).getValues(); if (!values.isEmpty()) return numericValueOf(values.get(0)); } return null; }
ValueUtil { public static Double numericValueOf(Object obj) { if (obj instanceof VNumber) { Number value = ((VNumber) obj).getValue(); if (value != null) { return value.doubleValue(); } } if (obj instanceof VBoolean) { return (double) (((VBoolean) obj).getValue() ? 1 : 0); } if (obj instanceof VEnum) { return (double) ((VEnum) obj).getIndex(); } if (obj instanceof VNumberArray) { ListNumber data = ((VNumberArray) obj).getData(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof VEnumArray) { ListNumber data = ((VEnumArray) obj).getIndexes(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof MultiScalar) { List values = ((MultiScalar) obj).getValues(); if (!values.isEmpty()) return numericValueOf(values.get(0)); } return null; } }
ValueUtil { public static Double numericValueOf(Object obj) { if (obj instanceof VNumber) { Number value = ((VNumber) obj).getValue(); if (value != null) { return value.doubleValue(); } } if (obj instanceof VBoolean) { return (double) (((VBoolean) obj).getValue() ? 1 : 0); } if (obj instanceof VEnum) { return (double) ((VEnum) obj).getIndex(); } if (obj instanceof VNumberArray) { ListNumber data = ((VNumberArray) obj).getData(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof VEnumArray) { ListNumber data = ((VEnumArray) obj).getIndexes(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof MultiScalar) { List values = ((MultiScalar) obj).getValues(); if (!values.isEmpty()) return numericValueOf(values.get(0)); } return null; } private  ValueUtil(); }
ValueUtil { public static Double numericValueOf(Object obj) { if (obj instanceof VNumber) { Number value = ((VNumber) obj).getValue(); if (value != null) { return value.doubleValue(); } } if (obj instanceof VBoolean) { return (double) (((VBoolean) obj).getValue() ? 1 : 0); } if (obj instanceof VEnum) { return (double) ((VEnum) obj).getIndex(); } if (obj instanceof VNumberArray) { ListNumber data = ((VNumberArray) obj).getData(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof VEnumArray) { ListNumber data = ((VEnumArray) obj).getIndexes(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof MultiScalar) { List values = ((MultiScalar) obj).getValues(); if (!values.isEmpty()) return numericValueOf(values.get(0)); } return null; } 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 Double numericValueOf(Object obj) { if (obj instanceof VNumber) { Number value = ((VNumber) obj).getValue(); if (value != null) { return value.doubleValue(); } } if (obj instanceof VBoolean) { return (double) (((VBoolean) obj).getValue() ? 1 : 0); } if (obj instanceof VEnum) { return (double) ((VEnum) obj).getIndex(); } if (obj instanceof VNumberArray) { ListNumber data = ((VNumberArray) obj).getData(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof VEnumArray) { ListNumber data = ((VEnumArray) obj).getIndexes(); if (data != null && data.size() != 0) { return data.getDouble(0); } } if (obj instanceof MultiScalar) { List values = ((MultiScalar) obj).getValues(); if (!values.isEmpty()) return numericValueOf(values.get(0)); } return null; } 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);  }