/** * Is used to overload implicit cast operators from char to * org.openl.meta.FloatValue * * @param x * @param y is needed to avoid ambiguity in Java method resolution * @return the casted value to org.openl.meta.FloatValue */ public static org.openl.meta.FloatValue autocast(char x, org.openl.meta.FloatValue y) { return new org.openl.meta.FloatValue((float) x); }
@Override public Float convert(FloatValue param) { if (param == null) { return null; } return param.floatValue(); };
public static FloatValue add(FloatValue value1, String value2) { if (value2 == null) { return value1; } if (value1 == null) { return new FloatValue(Float.valueOf(value2)); } float v = Float.valueOf(value2); return new org.openl.meta.FloatValue(value1, new FloatValue(v), Operators.add(value1.getValue(), v), Formulas.ADD); }
/** * Divides left hand operand by right hand operand * * @param value1 org.openl.meta.FloatValue * @param value2 org.openl.meta.FloatValue * @return the result of division operation */ public static org.openl.meta.FloatValue divide(org.openl.meta.FloatValue value1, org.openl.meta.FloatValue value2) { // temporary commented to support operations with nulls // // validate(value1, value2, Formulas.DIVIDE.toString()); if (value1 == null && value2 == null) { return null; } if (value1 == null) { if (value2 != null && value2.doubleValue() != 0) { return new org.openl.meta.FloatValue(value1, value2, divide(ONE, value2).getValue(), Formulas.DIVIDE); } } if (value2 == null) { return new org.openl.meta.FloatValue(value1, value2, value1.getValue(), Formulas.DIVIDE); } if (value2.doubleValue() == 0) { throw new OpenLRuntimeException("Division by zero"); } return new org.openl.meta.FloatValue(value1, value2, Operators.divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE); }
/** * Subtracts left hand operand to right hand operand * * @param value1 org.openl.meta.FloatValue * @param value2 org.openl.meta.FloatValue * @return the result of subtraction operation */ public static org.openl.meta.FloatValue subtract(org.openl.meta.FloatValue value1, org.openl.meta.FloatValue value2) { // temporary commented to support operations with nulls // // validate(value1, value2, Formulas.SUBTRACT.toString()); if (value1 == null && value2 == null) { return null; } if (value1 == null) { return negative(value2); } if (value2 == null) { return value1; } return new org.openl.meta.FloatValue(value1, value2, Operators.subtract(value1.getValue(), value2.getValue()), Formulas.SUBTRACT); }
public Float marshal(FloatValue val) throws Exception { return val.getValue(); } }
public static int cast(FloatValue x, int y) { return x.intValue(); }
public static byte cast(FloatValue x, byte y) { return x.byteValue(); }
/** * Copy the current value with new name <b>name</b> */ @Override public org.openl.meta.FloatValue copy(String name) { return copy(this, name); }
/** * * @param value * @return the <b>value</b> increased by 1 */ public static org.openl.meta.FloatValue inc(org.openl.meta.FloatValue value) { return add(value, ONE); }
public static DoubleValue convertToDoubleValue(Object object) { if (FloatValue.class.isAssignableFrom(object.getClass())) { return FloatValue.autocast((FloatValue) object, (DoubleValue) null); } if (DoubleValue.class.isAssignableFrom(object.getClass())) { return (DoubleValue) object; } if (BigDecimalValue.class.isAssignableFrom(object.getClass())) { return BigDecimalValue.cast((BigDecimalValue) object, (DoubleValue) null); } return new DoubleValue(convertToDouble(object)); }
/** * Divides left hand operand by right hand operand * * @param value1 org.openl.meta.FloatValue * @param value2 org.openl.meta.FloatValue * @return the result of division operation */ public static org.openl.meta.FloatValue divide(org.openl.meta.FloatValue value1, org.openl.meta.FloatValue value2) { // temporary commented to support operations with nulls // // validate(value1, value2, Formulas.DIVIDE.toString()); if (value1 == null && value2 == null) { return null; } if (value1 == null) { if (value2 != null && value2.doubleValue() != 0) { return new org.openl.meta.FloatValue(value1, value2, divide(ONE, value2).getValue(), Formulas.DIVIDE); } } if (value2 == null) { return new org.openl.meta.FloatValue(value1, value2, value1.getValue(), Formulas.DIVIDE); } if (value2.doubleValue() == 0) { throw new OpenLRuntimeException("Division by zero"); } return new org.openl.meta.FloatValue(value1, value2, Operators.divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE); }
/** * Subtracts left hand operand to right hand operand * * @param value1 org.openl.meta.FloatValue * @param value2 org.openl.meta.FloatValue * @return the result of subtraction operation */ public static org.openl.meta.FloatValue subtract(org.openl.meta.FloatValue value1, org.openl.meta.FloatValue value2) { // temporary commented to support operations with nulls // // validate(value1, value2, Formulas.SUBTRACT.toString()); if (value1 == null && value2 == null) { return null; } if (value1 == null) { return negative(value2); } if (value2 == null) { return value1; } return new org.openl.meta.FloatValue(value1, value2, Operators.subtract(value1.getValue(), value2.getValue()), Formulas.SUBTRACT); }
public Float marshal(FloatValue val) throws Exception { return val.getValue(); } }
public static int cast(FloatValue x, int y) { return x.intValue(); }
public static byte cast(FloatValue x, byte y) { return x.byteValue(); }
/** * Copy the current value with new name <b>name</b> */ @Override public org.openl.meta.FloatValue copy(String name) { return copy(this, name); }
/** * * @param value * @return the <b>value</b> increased by 1 */ public static org.openl.meta.FloatValue inc(org.openl.meta.FloatValue value) { return add(value, ONE); }
/** * Is used to overload implicit cast operators from long to * org.openl.meta.FloatValue * * @param x * @param y is needed to avoid ambiguity in Java method resolution * @return the casted value to org.openl.meta.FloatValue */ public static org.openl.meta.FloatValue autocast(long x, org.openl.meta.FloatValue y) { return new org.openl.meta.FloatValue((float) x); }
public static FloatValue add(String value1, FloatValue value2) { if (value1 == null) { return value2; } if (value2 == null) { return new FloatValue(Float.valueOf(value1)); } float v = Float.valueOf(value1); return new org.openl.meta.FloatValue(new FloatValue(v), value2, Operators.add(v, value2.getValue()), Formulas.ADD); }