summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/info
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2012-01-24 21:34:06 +0000
committerBrian S. O'Neill <bronee@gmail.com>2012-01-24 21:34:06 +0000
commit48fbe4abbd41c8faa0065a2be4f11839268bd0c7 (patch)
treeeed455fa39645a03cda7c966efe09515a40dcd41 /src/main/java/com/amazon/carbonado/info
parent6a25939edbeb0baea1c3e929a2e338335734dfda (diff)
Stricter property type checking, preventing verification errors in generated classes.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/info')
-rw-r--r--src/main/java/com/amazon/carbonado/info/StorableIntrospector.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
index 5ad6d20..1ec0575 100644
--- a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
+++ b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
@@ -1010,6 +1010,13 @@ public class StorableIntrospector {
("Must define proper 'get' method for property: " + property.getName());
}
} else {
+ if (readMethod.getReturnType() != property.getType()) {
+ errorMessages.add
+ ("Property type doesn't match accessor method return type: " +
+ property.getType().getName() + " != " + readMethod.getReturnType().getName() +
+ " for " + readMethod);
+ }
+
nullable = readMethod.getAnnotation(Nullable.class);
alias = readMethod.getAnnotation(Alias.class);
version = readMethod.getAnnotation(Version.class);
@@ -1062,6 +1069,16 @@ public class StorableIntrospector {
}
}
} else {
+ Class[] writeParams = writeMethod.getParameterTypes();
+ if (writeParams == null || writeParams.length != 1) {
+ errorMessages.add("Mutator method must contain one parameter: " + writeMethod);
+ } else if (writeParams[0] != property.getType()) {
+ errorMessages.add
+ ("Property type doesn't match mutator method parameter: " +
+ property.getType().getName() + " != " + writeParams[0].getName() +
+ " for " + writeMethod);
+ }
+
if (writeMethod.getAnnotation(Nullable.class) != null) {
errorMessages.add
("Nullable annotation not allowed on mutator: " + writeMethod);