Example usage for com.badlogic.gdx.utils.reflect Field getDeclaredAnnotation

List of usage examples for com.badlogic.gdx.utils.reflect Field getDeclaredAnnotation

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils.reflect Field getDeclaredAnnotation.

Prototype

public Annotation getDeclaredAnnotation(Class<? extends java.lang.annotation.Annotation> annotationType) 

Source Link

Document

Returns an Annotation object reflecting the annotation provided, or null of this field doesn't have such an annotation.

Usage

From source file:com.github.antag99.retinazer.WireCache.java

License:Open Source License

public WireCache(Engine engine, Class<?> type, WireResolver[] wireResolvers) {
    final List<Field> fields = new ArrayList<>();

    for (Class<?> current = type; current != Object.class; current = current.getSuperclass()) {
        for (Field field : ClassReflection.getDeclaredFields(current)) {
            if (field.getDeclaredAnnotation(Wire.class) == null) {
                continue;
            }// www.ja v a 2s .com

            if (field.isStatic()) {
                throw new RetinazerException(
                        "Static fields can not be wired (" + current.getName() + "#" + field.getName() + ")");
            }

            if (field.isSynthetic()) {
                continue;
            }

            field.setAccessible(true);
            fields.add(field);
        }
    }

    this.engine = engine;
    this.fields = fields.toArray(new Field[fields.size()]);
    this.wireResolvers = wireResolvers;
}