/** * Divides left hand operand by right hand operand * * @param number org.openl.meta.LongValue * @param divisor org.openl.meta.LongValue * @return LongValue the result of division operation */ public static LongValue quotient(org.openl.meta.LongValue number, org.openl.meta.LongValue divisor) { if (number != null && divisor != null) { LongValue result = new LongValue(MathUtils.quotient(number.getValue(), divisor.getValue())); return new LongValue(result, NumberOperations.QUOTIENT, null); } return null; }
public static double cast(LongValue x, double y) { return x.doubleValue(); }
public static int cast(LongValue x, int y) { return x.intValue(); }
/** * Is used to overload implicit cast operators from long to * org.openl.meta.LongValue * * @param x * @param y is needed to avoid ambiguity in Java method resolution * @return the casted value to org.openl.meta.LongValue */ public static org.openl.meta.LongValue autocast(long x, org.openl.meta.LongValue y) { return new org.openl.meta.LongValue((long) x); }
public static LongValue divide(LongValue value1, LongValue value2) { if (value1 == null && value2 == null) { return null; } if (value1 == null) { if (value2 != null && value2.doubleValue() != 0) { return new LongValue(value1, value2, divide(LongValue.ONE, value2).getValue(), Formulas.DIVIDE); } } if (value2 == null) { return new LongValue(value1, value2, value1.getValue(), Formulas.DIVIDE); } if (value2.doubleValue() == 0) { throw new OpenLRuntimeException("Division by zero"); } return new LongValue(value1, value2, divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE); }
/** * Subtracts left hand operand to right hand operand * * @param value1 org.openl.meta.LongValue * @param value2 org.openl.meta.LongValue * @return the result of subtraction operation */ public static org.openl.meta.LongValue subtract(org.openl.meta.LongValue value1, org.openl.meta.LongValue 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.LongValue(value1, value2, Operators.subtract(value1.getValue(), value2.getValue()), Formulas.SUBTRACT); }
if (value2 != null && value2.doubleValue() != 0) { return new org.openl.meta.DoubleValue(null, new DoubleValue(value2.doubleValue()), divide(ONE, value2).getValue(), Formulas.DIVIDE); return new org.openl.meta.DoubleValue(new DoubleValue(value1.doubleValue()), null, value1.getValue(), Formulas.DIVIDE); if (value2.doubleValue() == 0) { throw new OpenLRuntimeException("Division by zero"); return new org.openl.meta.DoubleValue(new DoubleValue(value1.doubleValue()), new DoubleValue(value2.doubleValue()), Operators.divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE);
public Long marshal(LongValue val) throws Exception { return val.getValue(); } }
/** Function constructor **/ public LongValue(LongValue result, NumberOperations function, LongValue[] params) { super(function, params); this.value = result.longValue(); }
public static byte cast(LongValue x, byte y) { return x.byteValue(); }
private static DoubleValue[] toDoubleValues(org.openl.meta.LongValue[] values) { if (values == null) { return null; } DoubleValue[] doubleValues = new DoubleValue[values.length]; int i = 0; for (LongValue value : values) { doubleValues[i] = autocast(value, DoubleValue.ZERO); i++; } return doubleValues; }
/** * Copy the current value with new name <b>name</b> */ @Override public org.openl.meta.LongValue copy(String name) { return copy(this, name); }
/** * * @param value * @return the <b>value</b> increased by 1 */ public static org.openl.meta.LongValue inc(org.openl.meta.LongValue value) { return add(value, ONE); }
/** * Is used to overload implicit cast operators from byte to * org.openl.meta.LongValue * * @param x * @param y is needed to avoid ambiguity in Java method resolution * @return the casted value to org.openl.meta.LongValue */ public static org.openl.meta.LongValue autocast(byte x, org.openl.meta.LongValue y) { return new org.openl.meta.LongValue((long) x); }
/** * Subtracts left hand operand to right hand operand * * @param value1 org.openl.meta.LongValue * @param value2 org.openl.meta.LongValue * @return the result of subtraction operation */ public static org.openl.meta.LongValue subtract(org.openl.meta.LongValue value1, org.openl.meta.LongValue 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.LongValue(value1, value2, Operators.subtract(value1.getValue(), value2.getValue()), Formulas.SUBTRACT); }
if (value2 != null && value2.doubleValue() != 0) { return new org.openl.meta.DoubleValue(null, new DoubleValue(value2.doubleValue()), divide(ONE, value2).getValue(), Formulas.DIVIDE); return new org.openl.meta.DoubleValue(new DoubleValue(value1.doubleValue()), null, value1.getValue(), Formulas.DIVIDE); if (value2.doubleValue() == 0) { throw new OpenLRuntimeException("Division by zero"); return new org.openl.meta.DoubleValue(new DoubleValue(value1.doubleValue()), new DoubleValue(value2.doubleValue()), Operators.divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE);
public Long marshal(LongValue val) throws Exception { return val.getValue(); } }
@Override public Long convert(LongValue param) { if (param == null) { return null; } return param.longValue(); };
public static byte cast(LongValue x, byte y) { return x.byteValue(); }
private static DoubleValue[] toDoubleValues(org.openl.meta.LongValue[] values) { if (values == null) { return null; } DoubleValue[] doubleValues = new DoubleValue[values.length]; int i = 0; for (LongValue value : values) { doubleValues[i] = autocast(value, DoubleValue.ZERO); i++; } return doubleValues; }