diff --git a/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java index fecf2a9c8..b65a719b6 100644 --- a/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java +++ b/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java @@ -120,9 +120,6 @@ public final class DefaultTypeManager implements TypeManager { private final ScalarType classType = new ScalarTypeClass(); - - private final List> customScalarTypes = new ArrayList<>(); - private final JsonConfig.DateTime jsonDateTime; private final Object objectMapper; @@ -185,7 +182,7 @@ public final class DefaultTypeManager implements TypeManager { loadTypesFromProviders(config, objectMapper); if (bootupClasses != null) { - initialiseCustomScalarTypes(jsonDateTime, bootupClasses); + initialiseCustomScalarTypes(bootupClasses); initialiseScalarConverters(bootupClasses); initialiseAttributeConverters(bootupClasses); } @@ -297,10 +294,6 @@ public final class DefaultTypeManager implements TypeManager { return null; } - private ScalarDataReader getScalarDataReader(Class type) { - return typeMap.get(type); - } - @Override public ScalarType getHstoreScalarType() { return (postgres) ? hstoreType : ScalarTypeJsonMap.typeFor(false, Types.VARCHAR); @@ -618,15 +611,9 @@ public final class DefaultTypeManager implements TypeManager { * interface and register it with this TypeManager. *

*/ - private void initialiseCustomScalarTypes(JsonConfig.DateTime mode, BootupClasses bootupClasses) { + private void initialiseCustomScalarTypes(BootupClasses bootupClasses) { - ScalarTypeLongToTimestamp longToTimestamp = new ScalarTypeLongToTimestamp(mode); - - customScalarTypes.add(longToTimestamp); - - List>> foundTypes = bootupClasses.getScalarTypes(); - - for (Class> cls : foundTypes) { + for (Class> cls : bootupClasses.getScalarTypes()) { try { ScalarType scalarType; @@ -653,7 +640,6 @@ public final class DefaultTypeManager implements TypeManager { private void addCustomType(ScalarType scalarType) { add(scalarType); - customScalarTypes.add(scalarType); } private Object initObjectMapper(ServerConfig serverConfig) { @@ -672,10 +658,9 @@ public final class DefaultTypeManager implements TypeManager { List>> foundTypes = bootupClasses.getScalarConverters(); for (Class> foundType : foundTypes) { - Class cls = foundType; try { - Class[] paramTypes = TypeReflectHelper.getParams(cls, ScalarTypeConverter.class); + Class[] paramTypes = TypeReflectHelper.getParams(foundType, ScalarTypeConverter.class); if (paramTypes.length != 2) { throw new IllegalStateException("Expected 2 generics paramtypes but got: " + Arrays.toString(paramTypes)); } @@ -688,13 +673,13 @@ public final class DefaultTypeManager implements TypeManager { throw new IllegalStateException("Could not find ScalarType for: " + paramTypes[1]); } - ScalarTypeConverter converter = (ScalarTypeConverter) cls.newInstance(); + ScalarTypeConverter converter = foundType.newInstance(); ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, converter); - logger.debug("Register ScalarTypeWrapper from " + logicalType + " -> " + persistType + " using:" + cls); + logger.debug("Register ScalarTypeWrapper from " + logicalType + " -> " + persistType + " using:" + foundType); add(stw); } catch (Exception e) { - logger.error("Error registering ScalarTypeConverter [" + cls.getName() + "]", e); + logger.error("Error registering ScalarTypeConverter [" + foundType.getName() + "]", e); } } } @@ -705,10 +690,9 @@ public final class DefaultTypeManager implements TypeManager { List>> foundTypes = bootupClasses.getAttributeConverters(); for (Class> foundType : foundTypes) { - Class cls = foundType; try { - Class[] paramTypes = TypeReflectHelper.getParams(cls, AttributeConverter.class); + Class[] paramTypes = TypeReflectHelper.getParams(foundType, AttributeConverter.class); if (paramTypes.length != 2) { throw new IllegalStateException("Expected 2 generics paramtypes but got: " + Arrays.toString(paramTypes)); } @@ -721,13 +705,13 @@ public final class DefaultTypeManager implements TypeManager { throw new IllegalStateException("Could not find ScalarType for: " + paramTypes[1]); } - AttributeConverter converter = (AttributeConverter) cls.newInstance(); + AttributeConverter converter = foundType.newInstance(); ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, new AttributeConverterAdapter(converter)); - logger.debug("Register ScalarTypeWrapper from " + logicalType + " -> " + persistType + " using:" + cls); + logger.debug("Register ScalarTypeWrapper from " + logicalType + " -> " + persistType + " using:" + foundType); add(stw); } catch (Exception e) { - logger.error("Error registering AttributeConverter [" + cls.getName() + "]", e); + logger.error("Error registering AttributeConverter [" + foundType.getName() + "]", e); } } } @@ -947,10 +931,8 @@ public final class DefaultTypeManager implements TypeManager { nativeMap.put(Types.DATE, dateType); ScalarType timestampType = new ScalarTypeTimestamp(mode); - typeMap.put(Timestamp.class, timestampType); nativeMap.put(Types.TIMESTAMP, timestampType); - } }