aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/iciql/TableDefinition.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2012-01-04 22:12:56 -0500
committerJames Moger <james.moger@gmail.com>2012-01-04 22:12:56 -0500
commit0932e559b420d46f8394a464c466804c1df0ede1 (patch)
tree822a49e35ce8ff3d7dd37cff84cf9e19bce0e6ae /src/com/iciql/TableDefinition.java
parentcc0c4f0e0b632ebfb1635e5ed2fe9a2119240157 (diff)
downloadiciql-0932e559b420d46f8394a464c466804c1df0ede1.tar.gz
iciql-0932e559b420d46f8394a464c466804c1df0ede1.zip
Disallow multiple instances of an enum within a model class
Diffstat (limited to 'src/com/iciql/TableDefinition.java')
-rw-r--r--src/com/iciql/TableDefinition.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java
index f7bbc13..b85b941 100644
--- a/src/com/iciql/TableDefinition.java
+++ b/src/com/iciql/TableDefinition.java
@@ -415,7 +415,30 @@ public class TableDefinition<T> {
void checkMultipleBooleans() {
if (multiplePrimitiveBools) {
throw new IciqlException(
- "Can not explicitly reference multiple primitive booleans in a model class!");
+ "Can not explicitly reference a primitive boolean if there are multiple boolean fields in your model class!");
+ }
+ }
+
+ void checkMultipleEnums(Object o) {
+ if (o == null) {
+ return;
+ }
+ Class<?> clazz = o.getClass();
+ if (!clazz.isEnum()) {
+ return;
+ }
+
+ int fieldCount = 0;
+ for (FieldDefinition fieldDef : fields) {
+ Class<?> targetType = fieldDef.field.getType();
+ if (clazz.equals(targetType)) {
+ fieldCount++;
+ }
+ }
+
+ if (fieldCount > 1) {
+ throw new IciqlException(
+ "Can not explicitly reference {0} because there are {1} {0} fields in your model class!", clazz.getSimpleName(), fieldCount);
}
}