DivideUtil { public static <T> ToDouble<T> doubleDivideDouble(ToDouble<T> first, double second) { return new DivideObjToDouble<T, ToDouble<T>, Double>(first) { @Override public double applyAsDouble(T object) { return this.first.applyAsDouble(object) / second; } @Override public Double second() { return second; } }; } private  DivideUtil(); static ToDouble<T> byteDivideInt(ToByte<T> first, int second); static ToDouble<T> byteDivideLong(ToByte<T> first, long second); static ToDouble<T> byteDivideDouble(ToByte<T> first, double second); static ToDouble<T> byteDivideInt(ToByte<T> first, ToInt<T> second); static ToDouble<T> byteDivideLong(ToByte<T> first, ToLong<T> second); static ToDouble<T> byteDivideDouble(ToByte<T> first, ToDouble<T> second); static ToDouble<T> shortDivideInt(ToShort<T> first, int second); static ToDouble<T> shortDivideLong(ToShort<T> first, long second); static ToDouble<T> shortDivideDouble(ToShort<T> first, double second); static ToDouble<T> shortDivideInt(ToShort<T> first, ToInt<T> second); static ToDouble<T> shortDivideLong(ToShort<T> first, ToLong<T> second); static ToDouble<T> shortDivideDouble(ToShort<T> first, ToDouble<T> second); static ToDouble<T> intDivideInt(ToInt<T> first, int second); static ToDouble<T> intDivideLong(ToInt<T> first, long second); static ToDouble<T> intDivideDouble(ToInt<T> first, double second); static ToDouble<T> intDivideInt(ToInt<T> first, ToInt<T> second); static ToDouble<T> intDivideLong(ToInt<T> first, ToLong<T> second); static ToDouble<T> intDivideDouble(ToInt<T> first, ToDouble<T> second); static ToDouble<T> longDivideInt(ToLong<T> first, int second); static ToDouble<T> longDivideLong(ToLong<T> first, long second); static ToDouble<T> longDivideDouble(ToLong<T> first, double second); static ToDouble<T> longDivideInt(ToLong<T> first, ToInt<T> second); static ToDouble<T> longDivideLong(ToLong<T> first, ToLong<T> second); static ToDouble<T> longDivideDouble(ToLong<T> first, ToDouble<T> second); static ToDouble<T> floatDivideInt(ToFloat<T> first, int second); static ToDouble<T> floatDivideLong(ToFloat<T> first, long second); static ToDouble<T> floatDivideDouble(ToFloat<T> first, double second); static ToDouble<T> floatDivideInt(ToFloat<T> first, ToInt<T> second); static ToDouble<T> floatDivideLong(ToFloat<T> first, ToLong<T> second); static ToDouble<T> floatDivideDouble(ToFloat<T> first, ToDouble<T> second); static ToDouble<T> doubleDivideInt(ToDouble<T> first, int second); static ToDouble<T> doubleDivideLong(ToDouble<T> first, long second); static ToDouble<T> doubleDivideDouble(ToDouble<T> first, double second); static ToDouble<T> doubleDivideInt(ToDouble<T> first, ToInt<T> second); static ToDouble<T> doubleDivideLong(ToDouble<T> first, ToLong<T> second); static ToDouble<T> doubleDivideDouble(ToDouble<T> first, ToDouble<T> second);  }
@Test void divideToDouble() { final ToDouble<String> toDouble = String::length; final DivideToDouble<String, ToDouble<String>, ToDouble<String>> divide = (DivideToDouble<String, ToDouble<String>, ToDouble<String>>) DivideUtil.doubleDivideDouble(toDouble, toDouble); assertEquals(Operator.DIVIDE, divide.operator()); assertNotNull(divide.first()); assertNotNull(divide.second()); assertNotEquals(0, divide.hashCode()); final DivideToDouble<String, ToDouble<String>, ToDouble<String>> copy = divide; assertTrue(divide.equals(copy)); assertFalse(divide.equals(null)); final DivideToDouble<String, ToDouble<String>, ToDouble<String>> another1 = new DivideToDouble<String, ToDouble<String>, ToDouble<String>>(divide.first(), divide.second()) { @Override public double applyAsDouble(String object) { return 0; } }; assertTrue(divide.equals(another1)); final DivideToDouble<String, ToDouble<String>, ToDouble<String>> another2 = new DivideToDouble<String, ToDouble<String>, ToDouble<String>>(divide.first(), ToDouble.constant(1)) { @Override public double applyAsDouble(String object) { return 0; } }; final DivideToDouble<String, ToDouble<String>, ToDouble<String>> another3 = new DivideToDouble<String, ToDouble<String>, ToDouble<String>>(ToDouble.constant(1), divide.second()) { @Override public double applyAsDouble(String object) { return 0; } }; assertFalse(divide.equals(another2)); }
@Test void divideObjToDouble() { final ToDouble<String> toDouble = String::length; final DivideObjToDouble<String, ToDouble<String>, Double> divide = (DivideObjToDouble<String, ToDouble<String>, Double>) DivideUtil.doubleDivideDouble(toDouble, 1); assertEquals(BinaryObjExpression.Operator.DIVIDE, divide.operator()); assertNotNull(divide.first()); assertNotEquals(0, divide.hashCode()); final DivideObjToDouble<String, ToDouble<String>, Double> copy = divide; assertTrue(divide.equals(copy)); assertFalse(divide.equals(null)); assertFalse(divide.equals(1)); final DivideObjToDouble<String, ToDouble<String>, Double> another1 = new DivideObjToDouble<String, ToDouble<String>, Double>(divide.first()) { @Override public Double second() { return null; } @Override public double applyAsDouble(String object) { return 0; } }; assertTrue(divide.equals(another1)); final DivideObjToDouble<String, ToDouble<String>, Double> another2 = new DivideObjToDouble<String, ToDouble<String>, Double>(ToDouble.constant(1)) { @Override public Double second() { return null; } @Override public double applyAsDouble(String object) { return 0; } }; assertFalse(divide.equals(another2)); }