use of com.hazelcast.sql.impl.type.converter.Converter in project hazelcast by hazelcast.
the class QueryDataTypeUtils method resolveTypeForClass.
@SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:ReturnCount", "checkstyle:MethodLength" })
public static QueryDataType resolveTypeForClass(Class<?> clazz) {
Converter converter = Converters.getConverter(clazz);
QueryDataTypeFamily typeFamily = converter.getTypeFamily();
switch(typeFamily) {
case VARCHAR:
if (converter == StringConverter.INSTANCE) {
return VARCHAR;
} else {
assert converter == CharacterConverter.INSTANCE;
return VARCHAR_CHARACTER;
}
case BOOLEAN:
return BOOLEAN;
case TINYINT:
return TINYINT;
case SMALLINT:
return SMALLINT;
case INTEGER:
return INT;
case BIGINT:
return BIGINT;
case DECIMAL:
if (converter == BigDecimalConverter.INSTANCE) {
return DECIMAL;
} else {
assert converter == BigIntegerConverter.INSTANCE;
return DECIMAL_BIG_INTEGER;
}
case REAL:
return REAL;
case DOUBLE:
return DOUBLE;
case DATE:
return DATE;
case TIME:
return TIME;
case TIMESTAMP:
return TIMESTAMP;
case TIMESTAMP_WITH_TIME_ZONE:
if (converter == DateConverter.INSTANCE) {
return TIMESTAMP_WITH_TZ_DATE;
} else if (converter == CalendarConverter.INSTANCE) {
return TIMESTAMP_WITH_TZ_CALENDAR;
} else if (converter == InstantConverter.INSTANCE) {
return TIMESTAMP_WITH_TZ_INSTANT;
} else if (converter == OffsetDateTimeConverter.INSTANCE) {
return TIMESTAMP_WITH_TZ_OFFSET_DATE_TIME;
} else {
assert converter == ZonedDateTimeConverter.INSTANCE;
return TIMESTAMP_WITH_TZ_ZONED_DATE_TIME;
}
case OBJECT:
case MAP:
return OBJECT;
case NULL:
return NULL;
case JSON:
return JSON;
default:
throw new IllegalArgumentException("Unexpected class: " + clazz);
}
}
use of com.hazelcast.sql.impl.type.converter.Converter in project hazelcast by hazelcast.
the class QueryDataTypeTest method testSerialization.
@Test
public void testSerialization() {
for (Converter converter : Converters.getConverters()) {
QueryDataType original = new QueryDataType(converter);
QueryDataType restored = serializeAndCheck(original, SqlDataSerializerHook.QUERY_DATA_TYPE);
checkEquals(original, restored, true);
}
}
Aggregations