Search in sources :

Example 1 with TypeReporter

use of eu.infomas.annotation.AnnotationDetector.TypeReporter in project bladecoder-adventure-engine by bladecoder.

the class ActionDetector method detect.

public static void detect() {
    actions = new HashMap<String, Class<?>>();
    final TypeReporter reporter = new TypeReporter() {

        @SuppressWarnings("unchecked")
        @Override
        public Class<? extends Annotation>[] annotations() {
            return new Class[] { ActionDescription.class };
        }

        @SuppressWarnings("unchecked")
        @Override
        public void reportTypeAnnotation(Class<? extends Annotation> annotation, String className) {
            Class<Action> c = null;
            try {
                c = ClassReflection.forName(className);
            } catch (ReflectionException e) {
                EditorLogger.printStackTrace(e);
            }
            String name = ActionUtils.getName(c);
            if (!c.isAssignableFrom(EndAction.class) && !c.isAssignableFrom(DisableActionAction.class))
                actions.put(name, c);
        }
    };
    final AnnotationDetector cf = new AnnotationDetector(reporter);
    try {
        cf.detect();
    } catch (IOException e) {
        EditorLogger.printStackTrace(e);
    }
}
Also used : TypeReporter(eu.infomas.annotation.AnnotationDetector.TypeReporter) ReflectionException(com.badlogic.gdx.utils.reflect.ReflectionException) EndAction(com.bladecoder.engine.actions.EndAction) Action(com.bladecoder.engine.actions.Action) DisableActionAction(com.bladecoder.engine.actions.DisableActionAction) ActionDescription(com.bladecoder.engine.actions.ActionDescription) AnnotationDetector(eu.infomas.annotation.AnnotationDetector) IOException(java.io.IOException) Annotation(java.lang.annotation.Annotation)

Aggregations

ReflectionException (com.badlogic.gdx.utils.reflect.ReflectionException)1 Action (com.bladecoder.engine.actions.Action)1 ActionDescription (com.bladecoder.engine.actions.ActionDescription)1 DisableActionAction (com.bladecoder.engine.actions.DisableActionAction)1 EndAction (com.bladecoder.engine.actions.EndAction)1 AnnotationDetector (eu.infomas.annotation.AnnotationDetector)1 TypeReporter (eu.infomas.annotation.AnnotationDetector.TypeReporter)1 IOException (java.io.IOException)1 Annotation (java.lang.annotation.Annotation)1