summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/iciql/util/Utils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-11-07 09:28:57 -0500
committerJames Moger <james.moger@gitblit.com>2014-11-09 11:15:14 -0500
commitdb0d58c22a0bd4fa2baf023428599757aa4db381 (patch)
tree9199c08f6b4c4eb217cf6ebb732d8ce5d9856a46 /src/main/java/com/iciql/util/Utils.java
parent468775706732f3e85af878710aaf95c81f5b60f2 (diff)
downloadiciql-db0d58c22a0bd4fa2baf023428599757aa4db381.tar.gz
iciql-db0d58c22a0bd4fa2baf023428599757aa4db381.zip
Revise type adapter definition to be a separate annotation
Diffstat (limited to 'src/main/java/com/iciql/util/Utils.java')
-rw-r--r--src/main/java/com/iciql/util/Utils.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/com/iciql/util/Utils.java b/src/main/java/com/iciql/util/Utils.java
index 346c6d7..bf66092 100644
--- a/src/main/java/com/iciql/util/Utils.java
+++ b/src/main/java/com/iciql/util/Utils.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringWriter;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -40,8 +41,10 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
+import com.iciql.Iciql.DataTypeAdapter;
import com.iciql.Iciql.EnumId;
import com.iciql.Iciql.EnumType;
+import com.iciql.Iciql.TypeAdapter;
import com.iciql.IciqlException;
/**
@@ -532,4 +535,24 @@ public class Utils {
in.close();
}
}
+
+ /**
+ * Identify the data type adapter class in the annotations.
+ *
+ * @param annotations
+ * @return null or the dtaa type adapter class
+ */
+ public static Class<? extends DataTypeAdapter<?>> getDataTypeAdapter(Annotation [] annotations) {
+ Class<? extends DataTypeAdapter<?>> typeAdapter = null;
+ if (annotations != null) {
+ for (Annotation annotation : annotations) {
+ if (annotation instanceof TypeAdapter) {
+ typeAdapter = ((TypeAdapter) annotation).value();
+ } else if (annotation.annotationType().isAnnotationPresent(TypeAdapter.class)) {
+ typeAdapter = annotation.annotationType().getAnnotation(TypeAdapter.class).value();
+ }
+ }
+ }
+ return typeAdapter;
+ }
}