Analize java annotations of getter method by property name

Get getter Method by property name

    protected Method methodGetter(String nombre){
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(enteClass);

            for(PropertyDescriptor cadaProp : beanInfo.getPropertyDescriptors()){
                    return cadaProp.getReadMethod();
        } catch (IntrospectionException ex) {
            Logger.getLogger(PropiedadCrud.class.getName()).log(Level.SEVERE, null, ex);
        return null;

Get Annotation object (null if doesn’t exist)

    Method metodo = this.methodGetter();
    FmField fmField = metodo.getAnnotation(FmField.class);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s