/** * Creates a constant expression that always return that object. * This is useful to test expressions or to introduce data that is available * at connection time at that will not change. * * @param <T> type of the value * @param value the actual value * @return an expression that is always going to return the given value */ public static <T> DesiredRateExpression<T> constant(T value) { return constant(value, value.toString()); }
static DesiredRateExpression<?> namedConstant(String constantName) { Object value = FormulaRegistry.getDefault().findNamedConstant(constantName); if (value == null) { throw new IllegalArgumentException("No constant named '" + constantName + "' is defined"); } return org.diirt.datasource.ExpressionLanguage.constant(value, constantName); }
/** * A constant representing an int. Alarm will be none, timestamp now * and no display information. * * @param value the constant value * @return an int expression */ public static DesiredRateExpression<VInt> vConst(int value) { return constant(newVInt(value, alarmNone(), timeNow(), displayNone()), Integer.toString(value)); }
/** * A constant representing a string. Alarm will be none and timestamp now. * * @param value the constant value * @return a string expression */ public static DesiredRateExpression<VString> vConst(String value) { return constant(newVString(value, alarmNone(), timeNow()), value); }
/** * A constant representing a double. Alarm will be none, timestamp now * and no display information. * * @param value the constant value * @return a double expression */ public static DesiredRateExpression<VDouble> vConst(double value) { return constant(newVDouble(value, alarmNone(), timeNow(), displayNone()), Double.toString(value)); }
/** * A constant representing a double array. Alarm will be none, timestamp now * and no display information. * * @param values the constant values * @return a double array expression */ public static DesiredRateExpression<VDoubleArray> vConst(ListDouble values) { return constant(newVDoubleArray(values, alarmNone(), timeNow(), displayNone())); }
/** * A constant representing an int array. Alarm will be none, timestamp now * and no display information. * * @param values the constant values * @return an int array expression */ public static DesiredRateExpression<VIntArray> vConst(ListInt values) { return constant(newVIntArray(values, alarmNone(), timeNow(), displayNone())); }
/** * A constant representing a double array. Alarm will be none, timestamp now * and no display information. * * @param values the constant values * @return a double array expression */ public static DesiredRateExpression<VDoubleArray> vConst(double... values) { return constant(newVDoubleArray(new ArrayDouble(values), alarmNone(), timeNow(), displayNone())); }
/** * A constant representing an int array. Alarm will be none, timestamp now * and no display information. * * @param values the constant values * @return an int array expression */ public static DesiredRateExpression<VIntArray> vConst(int... values) { return constant(newVIntArray(new ArrayInt(values), alarmNone(), timeNow(), displayNone())); }
/** * A list of constant expressions of type VString. * * @param values the list of constants * @return a list of string expression */ public static DesiredRateExpressionList<VString> vStringConstants(List<String> values) { DesiredRateExpressionList<VString> list = new DesiredRateExpressionListImpl<VString>(); for (String value : values) { list.and(constant(newVString(value, alarmNone(), timeNow()))); } return list; }
/** * A list of constant expressions of type VDouble. * * @param values the list of constants * @return a list of int expression */ public static DesiredRateExpressionList<VInt> vIntConstants(List<Integer> values) { DesiredRateExpressionList<VInt> list = new DesiredRateExpressionListImpl<VInt>(); for (Integer value : values) { list.and(constant(newVInt(value, alarmNone(), timeNow(), displayNone()))); } return list; }
/** * A list of constant expressions of type VDouble. * * @param values the list of constants * @return a list of double expression */ public static DesiredRateExpressionList<VDouble> vDoubleConstants(List<Double> values) { DesiredRateExpressionList<VDouble> list = new DesiredRateExpressionListImpl<VDouble>(); for (Double value : values) { list.and(constant(newVDouble(value, alarmNone(), timeNow(), displayNone()))); } return list; }