Here you can find the source of getAnnotationFields(Class claz, Class annotationType)
Parameter | Description |
---|---|
claz | a parameter |
annotationType | a parameter |
@SuppressWarnings({ "unchecked", "rawtypes" }) public static List<Field> getAnnotationFields(Class claz, Class annotationType)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; public class Main { /**/* w w w .ja va 2 s. c om*/ * get fields list of a type, and all the fields returned contains the given * annotation * * @param claz * @param annotationType * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static List<Field> getAnnotationFields(Class claz, Class annotationType) { List<Field> result = new ArrayList<Field>(); if (claz != null) { Field[] fields = claz.getDeclaredFields(); for (Field field : fields) { if (field.getAnnotation(annotationType) != null) { result.add(field); } } result.addAll(getAnnotationFields(claz.getSuperclass(), annotationType)); } return result; } }