All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.thucydides.core.annotations.AnnotatedFields Maven / Gradle / Ivy

There is a newer version: 0.9.275
Show newest version
package net.thucydides.core.annotations;


import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class AnnotatedFields {

    private final Class clazz;

    public static AnnotatedFields of(final Class testClass) {
        return new AnnotatedFields(testClass);
    }

    private AnnotatedFields(Class clazz) {
        this.clazz = clazz;
    }

    public Set allFields() {
        Set fields = new HashSet();
        fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
        fields.addAll(Arrays.asList(clazz.getFields()));
        if (clazz != Object.class) {
            fields.addAll(AnnotatedFields.of(clazz.getSuperclass()).allFields());
        }
        return fields;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy