Open francisconoriega opened 7 years ago
Works for me.
@Yky could you give an example of the field name and getter name you are using?
It should not work if you have something like mIsDefault
and then a getter called isDefault
and you can see in the generated method names code above, the method names this will produce are:
prefix.add("is" + AttributeHelper.getAttributeName(field));
=> isIsDefault
String fieldName = field.getName(); if (fieldName.length() > 2 && fieldName.startsWith("is") && Character.isUpperCase(fieldName.charAt(2))) prefix.add(fieldName);
=> mIsDefault
so you get isIsDefault
&& mIsDefault
but not isDefault
so you wont get the right method name
Why do you have the following line in your sample code.
prefix.add("is" + AttributeHelper.getAttributeName(field));
My tests work without this. The only registered prefix I have is "m".
When you have a boolean field that starts with with a prefix, followed by "is", openpojo will fail to find/associate its getter.
e.g.
boolean mIsDefault;
will try to find getters calledgetIsDefault
andisIsDefault
, but notisDefault
The issue is in
PojoMethodFactory.generateGetMethodNames
in this partthe first
prefix.add
will generate isIsDefault, the second prefix.add wont be executed because you are callingfieldName.startsWith
instead of AttributeHelper.getAttributeName(field).startsWith.You should also need add a toLower, making it