/** * Returns an array containing the categories to which the supplied class's properties are * assigned. */ public static String[] getCategories(Class<?> clazz) { String[] categories = _categories.get(clazz); if (categories == null) { categories = ArrayUtil.EMPTY_STRING; for (Property prop : getProperties(clazz)) { String category = prop.getAnnotation().category(); if (!ListUtil.contains(categories, category)) { categories = ArrayUtil.append(categories, category); } } if (DynamicallyEditable.class.isAssignableFrom(clazz)) { if (!ListUtil.contains(categories, "")) { categories = ArrayUtil.append(categories, ""); } } _categories.put(clazz, categories); } return categories; }
/** * Returns the arguments of the provided generic class or interface. * * @param type the type to search. * @param params the parameters to replace if the type is parameterized. * @param values the values with which to replace each parameter. * @param clazz the generic class of interface of interest. * @return the arguments of the generic class or interface, or <code>null</code> if not found. */ protected static Type[] getTypeArguments( Type type, TypeVariable[] params, Type[] values, Class<?> clazz) { if (type instanceof ParameterizedType) { ParameterizedType ptype = (ParameterizedType) type; Type[] args = ptype.getActualTypeArguments(); for (int ii = 0; ii < args.length; ii++) { Type arg = args[ii]; if (arg instanceof TypeVariable) { int idx = ListUtil.indexOf(params, arg); if (idx != -1) { args[ii] = values[idx]; } } } return getTypeArguments((Class<?>) ptype.getRawType(), args, clazz); } else if (type instanceof Class<?>) { return getTypeArguments((Class<?>) type, null, clazz); } return null; }