Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need ability to access annotations on objects #46

Closed
garpinc opened this issue Dec 12, 2012 · 7 comments
Closed

Need ability to access annotations on objects #46

garpinc opened this issue Dec 12, 2012 · 7 comments
Assignees
Milestone

Comments

@garpinc
Copy link

garpinc commented Dec 12, 2012

Hi.. Can you please add ability to access annotations on objects

in de.danielbechler.diff.accessor.Accessor add
Annotation getNodeAnnotation() throws Exception;
in de.danielbechler.diff.accessor.AbstractAccessor
@OverRide
public Annotation getNodeAnnotation() throws Exception {
return null;
}
in de.danielbechler.diff.accessor.PropertyAccessor
@OverRide
public Annotation getNodeAnnotation() throws Exception {
return readMethod.getAnnotations()[0];
}

This way in visitor I can do node.getNodeAnnotation() that potentially can have more info than just the type, value etc..

@SQiShER
Copy link
Owner

SQiShER commented Dec 12, 2012

I'm not sure I fully understand what you mean. Are you talking about a method that returns all annotations of the property or just one specialized annotation that's part of the library? Can you give me some examples of additional information would you put into these/this annotation(s)?

@garpinc
Copy link
Author

garpinc commented Dec 12, 2012

All annotations of a property

Or more generically just expose readMethod


From: Daniel Bechlermailto:[email protected]
Sent: ‎12/‎12/‎2012 6:05 PM
To: SQiShER/java-object-diffmailto:[email protected]
Cc: garpincmailto:[email protected]
Subject: Re: [java-object-diff] Need ability to access annotations on objects (#46)

I'm not sure I fully understand what you mean. Are you talking about a method that returns all annotations of the property or just one specialized annotation that's part of the library? Can you give me some examples of additional information would you put into these/this annotation(s)?


Reply to this email directly or view it on GitHub:
#46 (comment)

@SQiShER
Copy link
Owner

SQiShER commented Jan 3, 2013

Hey, sorry for the late response. The end of the year has been rather busy and didn't leave me much time. I think it's possible to add this feature, but I'm trying to remove the Accessor interface from the public API, so the annotation property actually needs to be part of the Node. It also needs to be able to return more than one annotation. I'll try to add this in the next feature release.

@ghost ghost assigned SQiShER Jan 3, 2013
@garpinc
Copy link
Author

garpinc commented Jan 3, 2013

Excellent..


From: Daniel Bechler
Sent: 1/3/2013 12:42 PM
To: SQiShER/java-object-diff
Cc: garpinc
Subject: Re: [java-object-diff] Need ability to access annotations on objects (#46)

Hey, sorry for the late response. The end of the year has been rather busy and didn't leave me much time. I think it's possible to add this feature, but I'm trying to remove the Accessor interface from the public API, so the annotation property actually needs to be part of the Node. It also needs to be able to return more than one annotation. I'll try to add this in the next feature release.


Reply to this email directly or view it on GitHub:
#46 (comment)

@SQiShER
Copy link
Owner

SQiShER commented Feb 9, 2013

I implemented this in in the latest commit. (Messed up the link to this ticket though.)

@garpinc
Copy link
Author

garpinc commented Feb 9, 2013

Could you also add this convenience method?

@SuppressWarnings("unchecked")
@Override
public <T> T getPropertyAnnotation(Class<T> annotationClass) {
    Set<Annotation> annotations = getPropertyAnnotations();
    if (annotations != null) {
        for (Annotation annotation : annotations) {
            if (annotationClass.isAssignableFrom(annotation.annotationType())) {
                return (T) annotation;
            }

        }
    }
    return null;
}

@SQiShER
Copy link
Owner

SQiShER commented Feb 10, 2013

Done. Added it to PropertyAccessor and Node.

@SQiShER SQiShER closed this as completed Feb 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants