diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-03 20:21:19 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-03 20:21:19 +0200 |
commit | df92538ab3d83da9839f08b28fc8a67317565463 (patch) | |
tree | a958d3cce1d3a9045c79371b182adb1ea6cf5a73 /container-compiler-plugin/src/main/java/io/trygvis/persistence/GeneratorConfiguration.java | |
parent | e1cf8889628d2d31cf7067b8c002f229fc22007d (diff) | |
download | container-playground-df92538ab3d83da9839f08b28fc8a67317565463.tar.gz container-playground-df92538ab3d83da9839f08b28fc8a67317565463.tar.bz2 container-playground-df92538ab3d83da9839f08b28fc8a67317565463.tar.xz container-playground-df92538ab3d83da9839f08b28fc8a67317565463.zip |
wip
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.java | 43 |
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); + } +} |