/** * Private helper to convert a float result. * * @param f The float to convert. */ private SoyValue convertResult(double f) { return FloatData.forValue(f); }
/** * Converts a double value to a SoyData (specifically a FloatData). * @param value The double value to convert. */ public static SoyData toSoyData(double value) { return FloatData.forValue(value); }
/** * Converts a double value to a SoyData (specifically a FloatData). * @param value The double value to convert. */ public static SoyData toSoyData(double value) { return FloatData.forValue(value); }
@Override public SoyValue apply(Double input) { return FloatData.forValue(input.doubleValue()); } });
@Override public SoyValue apply(Float input) { return FloatData.forValue(input.doubleValue()); } });
@Override public SoyValue apply(Float input) { return FloatData.forValue(input.doubleValue()); } });
/** * Adds a data value. * * @param value The data to add. */ public void add(double value) { add(FloatData.forValue(value)); }
/** * Puts data into this data tree at the specified key string. * * @param keyStr One or more map keys and/or list indices (separated by '.' if multiple parts). * Indicates the path to the location within this data tree. * @param value The data to put at the specified location. */ public void put(String keyStr, double value) { put(keyStr, FloatData.forValue(value)); }
/** * Sets a data value at a given index. * * @param index The index. * @param value The data to set. */ public void set(int index, double value) { set(index, FloatData.forValue(value)); }
/** * Adds a data value. * * @param value The data to add. */ public void add(double value) { add(FloatData.forValue(value)); }
/** * Puts data into this data tree at the specified key string. * * @param keyStr One or more map keys and/or list indices (separated by '.' if multiple parts). * Indicates the path to the location within this data tree. * @param value The data to put at the specified location. */ public void put(String keyStr, double value) { put(keyStr, FloatData.forValue(value)); }
/** Returns the numeric minimum of the two arguments. */ public static NumberData min(SoyValue arg0, SoyValue arg1) { if (arg0 instanceof IntegerData && arg1 instanceof IntegerData) { return IntegerData.forValue(Math.min(arg0.longValue(), arg1.longValue())); } else { return FloatData.forValue(Math.min(arg0.numberValue(), arg1.numberValue())); } }
/** Performs the unary negation {@code -} operator on the value. */ public static NumberData negative(SoyValue node) { if (node instanceof IntegerData) { return IntegerData.forValue(-node.longValue()); } else { return FloatData.forValue(-node.floatValue()); } }
/** Returns the numeric minimum of the two arguments. */ public static NumberData min(SoyValue arg0, SoyValue arg1) { if (arg0 instanceof IntegerData && arg1 instanceof IntegerData) { return IntegerData.forValue(Math.min(arg0.longValue(), arg1.longValue())); } else { return FloatData.forValue(Math.min(arg0.numberValue(), arg1.numberValue())); } }
/** Returns the numeric maximum of the two arguments. */ public static NumberData max(SoyValue arg0, SoyValue arg1) { if (arg0 instanceof IntegerData && arg1 instanceof IntegerData) { return IntegerData.forValue(Math.max(arg0.longValue(), arg1.longValue())); } else { return FloatData.forValue(Math.max(arg0.numberValue(), arg1.numberValue())); } } /** Returns the numeric minimum of the two arguments. */
/** Performs the unary negation {@code -} operator on the value. */ public static NumberData negative(SoyValue node) { if (node instanceof IntegerData) { return IntegerData.forValue(-node.longValue()); } else { return FloatData.forValue(-node.floatValue()); } }
/** Performs the {@code -} operator on the two values. */ public static SoyValue minus(SoyValue operand0, SoyValue operand1) { if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) { return IntegerData.forValue(operand0.longValue() - operand1.longValue()); } else { return FloatData.forValue(operand0.numberValue() - operand1.numberValue()); } }
/** Performs the {@code *} operator on the two values. */ public static NumberData times(SoyValue operand0, SoyValue operand1) { if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) { return IntegerData.forValue(operand0.longValue() * operand1.longValue()); } else { return FloatData.forValue(operand0.numberValue() * operand1.numberValue()); } }
/** Performs the {@code -} operator on the two values. */ public static SoyValue minus(SoyValue operand0, SoyValue operand1) { if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) { return IntegerData.forValue(operand0.longValue() - operand1.longValue()); } else { return FloatData.forValue(operand0.numberValue() - operand1.numberValue()); } }
/** Performs the {@code +} operator on the two values. */ public static SoyValue plus(SoyValue operand0, SoyValue operand1) { if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) { return IntegerData.forValue(operand0.longValue() + operand1.longValue()); } else if (operand0 instanceof NumberData && operand1 instanceof NumberData) { return FloatData.forValue(operand0.numberValue() + operand1.numberValue()); } else { // String concatenation is the fallback for other types (like in JS). Use the implemented // coerceToString() for the type. return StringData.forValue(operand0.coerceToString() + operand1.coerceToString()); } }