summaryrefslogtreecommitdiff
path: root/container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java')
-rw-r--r--container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java b/container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java
new file mode 100644
index 0000000..37d8146
--- /dev/null
+++ b/container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java
@@ -0,0 +1,43 @@
+package io.trygvis.persistence;
+
+import io.trygvis.container.compiler.CompilerException;
+import io.trygvis.container.compiler.model.TypeRef;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class GeneratorConfiguration {
+
+ private final Map<TypeRef, TypeHandler> primitiveTypeHandlers = new TreeMap<>();
+ private final Map<TypeRef, TypeHandler> typeHandlers = new TreeMap<>();
+
+ {
+ typeHandlers.put(new TypeRef(Integer.class), new TypeHandler.IntTypeHandler());
+ typeHandlers.put(new TypeRef(Long.class), new TypeHandler.LongTypeHandler());
+ typeHandlers.put(new TypeRef(String.class), new TypeHandler.StringTypeHandler());
+ typeHandlers.put(new TypeRef(Date.class), new TypeHandler.DateTypeHandler());
+
+ primitiveTypeHandlers.putAll(typeHandlers);
+ }
+
+ public void addTypeHandler(TypeRef type, TypeHandler typeHandler) {
+ typeHandlers.put(type, typeHandler);
+ }
+
+ public TypeHandler typeHandler(TypeRef type) {
+ TypeHandler typeHandler = typeHandlers.get(type);
+ if (typeHandler == null) {
+ throw new CompilerException("Unsupported field type: " + type.fqName);
+ }
+ return typeHandler;
+ }
+
+ public boolean isPrimitive(TypeRef type) {
+ return primitiveTypeHandlers.containsKey(type);
+ }
+
+ public boolean hasTypeHandler(TypeRef type) {
+ return typeHandlers.containsKey(type);
+ }
+}