i have a class like this
public class Student
{
private String reference;
private String aPlaceAt;
//methods generate by Netbeans Eclipse generates the same methods
public String getaPlaceAt(){return aPlaceAt;}
public void setaPlaceAt(String aPlaceAt){this.aPlaceAt = aPlaceAt;}
public String getReference(){return reference;}
public void setReference(String reference){this.reference = reference;}
}
later i need to find the setters and getters by each property by reflection
i am using the following code
public Method findSetterFor(final Class clazz,final String propertyName) throws Exception
{
return new PropertyDescriptor(propertyName,clazz).getWriteMethod();
}
for(final Field field:clazz.testClazz.getDeclaredFields())
System.out.println(field.getName()+" "+clazz.findSetterFor(clazz.testClazz,field.getName()));
they return the correct setter for reference but for the property aPlaceAt
throws
Exception in thread "main" java.beans.IntrospectionException: Method not found: isAPlaceAt
why isAPlaceAt? not should be
public void setaPlaceAt(String aPlaceAt){this.aPlaceAt = aPlaceAt;}?
or why i am doing wrong? how can accomplish it thanks?
i think the setters and getters are generate correctly according to other post at SO and this link
the methods are generate by Netbeans and Eclipse and intellij
UPDATE here is another hot forum about it this same problem please check it out