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

io.zulia.util.AnnotationUtil Maven / Gradle / Ivy

There is a newer version: 1.6.4
Show newest version
package io.zulia.util;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;

public class AnnotationUtil {
	public static List getNonStaticFields(final Class clazz, boolean deep) {
		List fields = new ArrayList<>();
		for (Field f : clazz.getDeclaredFields()) {
			if (!Modifier.isStatic(f.getModifiers())) {
				fields.add(f);
			}
		}

		if (deep) {
			Class parent = clazz.getSuperclass();
			while ((parent != null) && (parent != Object.class)) {
				for (Field f : parent.getDeclaredFields()) {
					if (!Modifier.isStatic(f.getModifiers())) {
						fields.add(f);
					}
				}

				parent = parent.getSuperclass();
			}
		}

		return fields;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy