Hmm ...
The fix you committed trims off the "is" always, but I have quite a lot of Shorts using "is" as name prefix.
These fields have the name stripped now too.
The methods also are named getIsX() and setIsX(), so, technically spoken, my fields and methods follow the Bean-Spec.
I'd vote to enhance the patch to check against which methods are existent and strip based on this information, or (I think even better) rollback this change, as the developer should fix their entities if they do not follow the spec.
However, at least I'd like to ask if you could check for boolean explicitely:
Index: ../ebean/src/com/avaje/ebean/enhance/agent/FieldMeta.java
===================================================================
--- ../ebean/src/com/avaje/ebean/enhance/agent/FieldMeta.java (revision 178)
+++ ../ebean/src/com/avaje/ebean/enhance/agent/FieldMeta.java Tue Mar 24 11:44:46 CET 2009
@@ -89,7 +89,7 @@
publicGetterName = name;
} else {
- String publicFieldName = getFieldName(name);
+ String publicFieldName = getFieldName(name, asmType);
// use java bean property name convention
String initCap = Character.toUpperCase(publicFieldName.charAt(0))+publicFieldName.substring(1);
publicSetterName = "set"+initCap;
@@ -110,8 +110,8 @@
/**
* Handle the case where a boolean variable starts with 'is'.
*/
- private String getFieldName(String name){
- if (name.startsWith("is") && name.length() > 2){
+ private String getFieldName(String name, Type asmType){
+ if (asmType.equals(Type.BOOLEAN_TYPE) && name.startsWith("is") && name.length() > 2){
char c = name.charAt(2);
if (Character.isUpperCase(c)){
if (classMeta.isLog(6)) {
Index: ../ebean/src/com/avaje/ebean/server/deploy/parse/CreateProperties.java
===================================================================
--- ../ebean/src/com/avaje/ebean/server/deploy/parse/CreateProperties.java (revision 178)
+++ ../ebean/src/com/avaje/ebean/server/deploy/parse/CreateProperties.java Tue Mar 24 11:44:46 CET 2009
@@ -188,7 +187,7 @@
private String getFieldName(Field field, Class> beanType){
String name = field.getName();
- if (name.startsWith("is") && name.length() > 2){
+ if ((Boolean.class.equals(field.getType()) || boolean.class.equals(field.getType())) && name.startsWith("is") && name.length() > 2){
char c = name.charAt(2);
if (Character.isUpperCase(c)){
String msg = "trimming off 'is' from field name "+name+" in class "+beanType.getName();
Thanks!
Ciao,
Mario