Package com.mastfrog.acteur
Class HelpGenerator.AnnotationDescriptionPlugin<T extends Annotation>
java.lang.Object
com.mastfrog.acteur.HelpGenerator.AnnotationDescriptionPlugin<T>
- Type Parameters:
T-
- Enclosing class:
- HelpGenerator
public abstract static class HelpGenerator.AnnotationDescriptionPlugin<T extends Annotation>
extends Object
Allows code to be plugged in to contribute to the help page information
about specific types of annotation. To plug one in, implement and bind as
an eager singleton.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAnnotationDescriptionPlugin(Class<T> annotationType, HelpGenerator gen) -
Method Summary
Modifier and TypeMethodDescriptionprotected final StringConvert typical Java constant naming conventions - e.g.protected final voidintrospectAnnotation(Application application, Annotation a, Map<String, Object> into) Introspect, continuing the help mechanism, an annotation found when examining the annotation passed towrite()(but must not be the annotation passed there).protected final StringreflectAndJsonify(Application application, String field, Class<?> type) Used for examples - looks up the given static field by reflection and returns an html-ized JSONified view of its contents.protected abstract voidAdd key/value pairs to the passed map, describing this annotation, for the JSON help description.
-
Constructor Details
-
AnnotationDescriptionPlugin
-
-
Method Details
-
deConstantNameify
Convert typical Java constant naming conventions - e.g. FOO_BAR_BAZ into a documentation-friendly string "Foo Bar Baz".- Parameters:
s- The string- Returns:
- A munged version of the passed strings
-
introspectAnnotation
protected final void introspectAnnotation(Application application, Annotation a, Map<String, Object> into) throws IllegalAccessException, IllegalArgumentException, InvocationTargetExceptionIntrospect, continuing the help mechanism, an annotation found when examining the annotation passed towrite()(but must not be the annotation passed there). If your annotation, say, inserts additional Acteurs in the chain, whose behavior should be reflected in the help - @Precursors and @Concluders are examples of this - call this method to automatically look up and use any plugins needed. Typically, yourwrite()method will create and add a new sub-map which you pass to this method, to the map you were passed.- Parameters:
application- The application instancea- The annotationinto- The map to write into- Throws:
IllegalAccessException- If reflection failsIllegalArgumentException- If reflection failsInvocationTargetException- If reflection fails
-
reflectAndJsonify
Used for examples - looks up the given static field by reflection and returns an html-ized JSONified view of its contents.- Parameters:
application- The applicationfield- The field nametype- The type the field is on- Returns:
- A description or null if something goes wrong
-
write
Add key/value pairs to the passed map, describing this annotation, for the JSON help description.- Parameters:
addTo- The map to add toanno- The annotation
-