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

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

Introduction

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

Prototype

public boolean isSynthetic() 

Source Link

Document

Return true if the field is a synthetic field.

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;
            }//ww  w. j  a  v a2 s.  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;
}

From source file:mt.Json.java

License:Apache License

private ObjectMap<String, FieldMetadata> cacheFields(Class type) {
    ArrayList<Field> allFields = new ArrayList();
    Class nextClass = type;// ww w. j a va  2s .  c  om
    while (nextClass != Object.class) {
        Collections.addAll(allFields, ClassReflection.getDeclaredFields(nextClass));
        nextClass = nextClass.getSuperclass();
    }

    ObjectMap<String, FieldMetadata> nameToField = new ObjectMap();
    for (int i = 0, n = allFields.size(); i < n; i++) {
        Field field = allFields.get(i);

        if (field.isTransient())
            continue;
        if (field.isStatic())
            continue;
        if (field.isSynthetic())
            continue;

        if (!field.isAccessible()) {
            try {
                field.setAccessible(true);
            } catch (AccessControlException ex) {
                continue;
            }
        }

        nameToField.put(field.getName(), new FieldMetadata(field));
    }
    typeToFields.put(type, nameToField);
    return nameToField;
}