TypeUtil { static public OpType getOpType(DataType dataType){ switch(dataType){ case STRING: return OpType.CATEGORICAL; case INTEGER: case FLOAT: case DOUBLE: return OpType.CONTINUOUS; case BOOLEAN: return OpType.CATEGORICAL; case DATE: case TIME: case DATE_TIME: return OpType.ORDINAL; case DATE_DAYS_SINCE_0: case DATE_DAYS_SINCE_1960: case DATE_DAYS_SINCE_1970: case DATE_DAYS_SINCE_1980: case TIME_SECONDS: case DATE_TIME_SECONDS_SINCE_0: case DATE_TIME_SECONDS_SINCE_1960: case DATE_TIME_SECONDS_SINCE_1970: case DATE_TIME_SECONDS_SINCE_1980: return OpType.CONTINUOUS; default: throw new IllegalArgumentException(); } } private  TypeUtil(); static String format(Object value); static Object parseOrCast(DataType dataType, Object value); static Object parse(DataType dataType, String value); static DaysSinceDate parseDaysSinceDate(LocalDate epoch, String value); static boolean equals(DataType dataType, Object value, Object referenceValue); static DataType getDataType(Object value); static DataType getDataType(Collection<?> values); static DataType getCommonDataType(DataType left, DataType right); static OpType getOpType(DataType dataType); static Object cast(DataType dataType, Object value); static V cast(Class<? extends V> clazz, Object value); static DataType getConstantDataType(Object value); static DataType getConstantDataType(String value);  }
@Test public void getOpType(){ assertEquals(OpType.ORDINAL, TypeUtil.getOpType(DataType.DATE)); assertEquals(OpType.ORDINAL, TypeUtil.getOpType(DataType.TIME)); assertEquals(OpType.ORDINAL, TypeUtil.getOpType(DataType.DATE_TIME)); assertEquals(OpType.CONTINUOUS, TypeUtil.getOpType(DataType.DATE_DAYS_SINCE_1970)); assertEquals(OpType.CONTINUOUS, TypeUtil.getOpType(DataType.TIME_SECONDS)); assertEquals(OpType.CONTINUOUS, TypeUtil.getOpType(DataType.DATE_TIME_SECONDS_SINCE_1970)); }