Meta

Annotations are a big part of the java language. It makes the code easier yet powerful. But annotations has so many limitations and can't specify that much data without base annotations to depend on. This package provides base annotations that have so many uses.


Filter
GitHub Javadoc


You may have a method that can accept number of classes, meanwhile those classes aren't related. You may specify those classes one by one, or use the annotation Filter. This annotation can accept a range of classes, exclude some, include absolute classes making it more useful for dealing with unknown range of types.

    //this filter will include String.class, any Collection, 
    //but not any class extends List.class or the class HashSet
    @Filter(
        include = String.class,
        exclude = HashSet.class,
        includeAll = Collection.class,
        excludeAll = List.class
    )


Recipe
GitHub Javadoc


Annotations don't allow constructing new objects. But we can pass the recipe about how to construct those objects. Giving the source string, and the clazz of that object, and a converter to be used to convert that object. It is easy not to pass objects using annotations.

    //the following object will be an integer with the value 9
    @Recipe(
        value = "9",
        type = @Type(Integer.class)
    )


Type
GitHub Javadoc


As we can't construct objects. We can't construct clazzes. So this annotation is the replacement of the class Clazz.

    //this is clazz of an ArrayList that should be treated
    //as a Set an its component type is String
    @Type(
        value = ArrayList.class,
        family = Set.class,
        componentTypes = String.class
    )


Where
GitHub Javadoc


Navigating to a field in annotations seems a bit hard. So the annotation where is like the path-map to where a specific field located at.

    class SomeWhere {
        //the id tells exactly what field we are looking for
        @Where(id = "here")
        public int myField;
    }

    //this will give us the location of the field above
    @Where(
        value = SomeWhere.class,
        id = "here"
    )