CastUtil { public static <T> ToDouble<T> castBooleanToDouble(ToBoolean<T> original) { class BooleanToDouble extends CastToDouble<T, ToBoolean<T>> { private BooleanToDouble(ToBoolean<T> tToBoolean) { super(tToBoolean); } @Override public double applyAsDouble(T object) { return inner.applyAsBoolean(object) ? 1 : 0; } } return new BooleanToDouble(original); } private  CastUtil(); static ToDouble<T> castByteToDouble(ToByte<T> original); static ToDouble<T> castShortToDouble(ToShort<T> original); static ToDouble<T> castIntToDouble(ToInt<T> original); static ToDouble<T> castLongToDouble(ToLong<T> original); static ToDouble<T> castFloatToDouble(ToFloat<T> original); static ToDouble<T> castBigDecimalToDouble(ToBigDecimal<T> original); static ToDouble<T> castBooleanToDouble(ToBoolean<T> original); static ToDouble<T> castCharToDouble(ToChar<T> original); static ToInt<T> castByteToInt(ToByte<T> original); static ToInt<T> castShortToInt(ToShort<T> original); static ToInt<T> castLongToInt(ToLong<T> original); static ToInt<T> castFloatToInt(ToFloat<T> original); static ToInt<T> castDoubleToInt(ToDouble<T> original); static ToInt<T> castBigDecimalToInt(ToBigDecimal<T> original); static ToInt<T> castBooleanToInt(ToBoolean<T> original); static ToInt<T> castCharToInt(ToChar<T> original); static ToLong<T> castByteToLong(ToByte<T> original); static ToLong<T> castShortToLong(ToShort<T> original); static ToLong<T> castIntToLong(ToInt<T> original); static ToLong<T> castFloatToLong(ToFloat<T> original); static ToLong<T> castDoubleToLong(ToDouble<T> original); static ToLong<T> castBigDecimalToLong(ToBigDecimal<T> original); static ToLong<T> castBooleanToLong(ToBoolean<T> original); static ToLong<T> castCharToLong(ToChar<T> original);  }
@Test void castBooleanToDouble() { final ToDouble<String> toDouble = CastUtil.castBooleanToDouble(Objects::nonNull); assertNotNull(toDouble); assertEquals(1, toDouble.applyAsDouble("")); assertEquals(0, toDouble.applyAsDouble(null)); }