podam
podam copied to clipboard
Arrays.asList() is implemented AbstractList, is not work to add method
public static List<Annotation> getAttributeAnnotations(final Field attribute,
final Method setter) {
Annotation[] annotations = (attribute != null ? attribute.getAnnotations() : null);
List<Annotation> retValue;
if (annotations != null && annotations.length != 0) {
retValue = Arrays.asList(annotations);
} else {
retValue = new ArrayList<Annotation>();
}
for (Annotation annotation : setter.getParameterAnnotations()[0]) {
retValue.add(annotation);
}
return retValue;
}
// this code is not work. for (Annotation annotation : setter.getParameterAnnotations()[0]) { retValue.add(annotation); }
//retValue is AbstractList. then is not work to add method, see this AbstractList.java:148 code
It's not java.util.AbstractList, but java.util.Arrays.ArrayList, which is immutable.
Just try this POJO
public class AnnotatedPojo {
@PodamStringValue(strValue = "XYZ")
private String postCode;
public String getPostCode() {
return postCode;
}
public void setPostCode(@PodamStringValue(strValue = "XYZ") String postCode) {
this.postCode = postCode;
}
}