Add Annotation retrieval methods to `Property`

Issue #307 new
Anonymous created an issue

As a developer attempting to expose a user-facing YAML document I want to have access to a Property's annotations, so that I can easily configure the order of fields.

Hey guys,

I only discovered the YAML document format a while ago and fell in love with it when I did. Our application involves a fairly sophisicated configuration stage, and we're in the process of adding command-line operation to our application, so we need a document format that can be hand-written by users. YAML jumped out at me.

The problem is that once the document has been given to our application, we would like to be able to constructor our native type from the document, and then represent that type in as close to the original document as possible.

this means giving our users an intuitive ~field~ order and then enforcing it on representation. I've already written some runtime facilities to keep track of source-code field order for JNA, so I'd like to leverage the existing facilities I have there to impose field order.

This means I need annotations, and i need to be able to get those annotations easily from your API.

I would like to change the Properties class to support a

public Set<Annotation> getAnnotations();

method to the Property interface.

This would simply return field.getAnnotations() in the case of a field, it would return the getter methods annotations in the case of a MethodProperty, and the empty set in the case of the MissingProperty

Thanks to the simplicity and compactness of SnakeYAML, I'm fairly sure I can implement this. Let me know if I'm cleared to do this!


Comments (5)

  1. maslovalex

    I think the idea to give access to Annotations is nod a bad one. Maybe it could be used by others to implement something else. Should we follow java's way: getAnnotations and getDeclaredAnnotations ?

  2. maslovalex

    BTW, in JDK :

    Annotations[] getAnnotations();
    Annotations[] getDeclaredAnnotations();

    There are some other "standard" methods to work with annotations, but not sure if we need those.

    @Geoff Groos it would be nice to see some code. We could see if these changes are general enough to be added to the project.

  3. Log in to comment