protected static Map<String, Object> collectConstants(Class<?> type) {
        Map<String, Object> constants = new ConstantsHashMap<>(type);

        // Go through all the fields, and put static ones in a map.
        Field[] fields = type.getFields();

        for (Field field : fields) {
            // already collected in a class with higher prio
            if (constants.containsKey(field.getName())) {
                continue;
            }

            // Check to see if this is public static final. If not, it's not a constant.
            int modifiers = field.getModifiers();
            if (!Modifier.isFinal(modifiers) || !Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
                continue;
            }

            try {
                Object value = field.get(null); // null for static fields.
                constants.put(field.getName(), value);
            }
            catch (Exception e) {
                throw new FacesException("Could not get value of " + field.getName() + " in " + type.getName() + ".", e);
            }
        }

        return constants;
    }
Collects all constants of the given {@link Class}.

@param type The class which includes the constants.
@return A {@link Map} with the found constants.
primefaces/src/main/java/org/primefaces/component/importconstants/ImportConstantsTagHandler.java