Java Code Examples for java.lang.reflect.Field.isEnumConstant()

The following are Jave code examples for showing how to use isEnumConstant() of the java.lang.reflect.Field class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: framework   File: CommonUtils.java   View Source Code Vote up 6 votes
public static Field[] getCanSerializeField(Class<?> clazz) {
	Field[] fields = clazz.getDeclaredFields();
	List<Field> canSerializeFields = new ArrayList<Field>();
	for (Field field : fields) {
		if (field.getName().equals("__PARANAMER_DATA")) {
			continue;
		}
		if (field.isEnumConstant()) {
			continue;
		}
		if (field.getType() == Date.class) {
			continue;
		}
		if ((field.getModifiers() & Modifier.FINAL) == Modifier.FINAL) {
			continue;
		}
		canSerializeFields.add(field);
	}
	Field[] newFields = new Field[canSerializeFields.size()];
	return canSerializeFields.toArray(newFields);
}
 
Example 2
Project: JavaGraph   File: FormulaParser.java   View Source Code Vote up 6 votes
/**
 * Computes a mapping from syntax documentation lines to associated (possibly {@code null}) tooltips.
 * @param logic the logic variant concerned
 */
private static Map<String,String> computeDocMap(Logic logic) {
    Map<String,String> result = new LinkedHashMap<>();
    for (Field field : LogicOp.class.getFields()) {
        if (field.isEnumConstant()) {
            LogicOp token = nameToTokenMap.get(field.getName());
            if (logic.getOps()
                .contains(token)) {
                Help help = Help.createHelp(field, nameToSymbolMap);
                if (help != null) {
                    result.put(help.getItem(), help.getTip());
                }
            }
        }
    }
    return result;
}
 
Example 3
Project: ProjectAres   File: DocumentRegistry.java   View Source Code Vote up 5 votes
private void registerField(Map<String, Getter> getters, Map<String, Setter> setters, Field field) {
    if(Modifier.isTransient(field.getModifiers()) ||
       Modifier.isStatic(field.getModifiers()) ||
       field.isSynthetic() ||
       field.isEnumConstant()) return;

    final String name = serializedName(field);
    final boolean gettable = !getters.containsKey(name);
    final boolean settable = !setters.containsKey(name);

    if(gettable || settable) {
        if(logger.isLoggable(Level.FINE)) {
            String access;
            if(gettable && settable) {
                access = "get/set";
            } else if(gettable) {
                access = "get";
            } else {
                access = "set";
            }
            logger.fine("  " + name + " -- " + access + " --> " + field);
        }

        if(gettable) {
            getters.put(name, new FieldGetter(this, field));
        }

        if(settable) {
            setters.put(name, new FieldSetter(this, field));
        }
    }
}
 
Example 4
Project: ciguan   File: AsGlobalDataSources.java   View Source Code Vote up 5 votes
/**
 * Creates the enum list.
 *
 * @param pEnumClass the enum class
 */
public void createEnumList(Class<?> pEnumClass) {
    // If the data source already exists, do nothing
    AsListIf<?> tDictionary = (AsListIf<?>) getDataSource(CwfGlobalDataSources.DICTIONARY, null, null);
    if (tDictionary == null) {
        AsLoggerIf.Singleton.get().log("Attempting to register enum " + pEnumClass +
            " before the dictionary exists");
        return;
    }

    if (getDataSource(As.getTypeName(pEnumClass), null, null) != null) {
        return;
    }

    AsEmapiTreeMapList<AsEnumValueData> tList = new AsEmapiTreeMapList<AsEnumValueData>(
        As.getTypeName(pEnumClass), AsEnumValueData.class, ATTR_ENUM_NAME, ATTR_ENUM_VALUE);

    try {
        for (Field tField : pEnumClass.getFields()) {
            if (tField.isEnumConstant()) {
                String tValue = tField.get(null).toString();
                String tName = tField.getName();
                AsDictionaryWord tTranslation = (AsDictionaryWord) tDictionary.get(
                    ".enum." + As.getTypeName(pEnumClass) + "." + tName);
                if (tTranslation == null) {
                    tTranslation = (AsDictionaryWord) tDictionary.get(".enum." + tName);
                }
                AsEnumValueData tEnumData = new AsEnumValueData(
                    As.getTypeName(pEnumClass), tName, tValue, tTranslation);
                tList.add(tEnumData);
            }
        }
    }
    catch (Exception e) {
        // Fatal, abort
        As.systemExit("Could not create constant group list", e);
    }

    putDataSource(tList);
}
 
Example 5
Project: lams   File: AnnotationMapper.java   View Source Code Vote up 4 votes
private void processTypes(final Set<Class<?>> types) {
    while (!types.isEmpty()) {
        final Iterator<Class<?>> iter = types.iterator();
        final Class<?> type = iter.next();
        iter.remove();

        synchronized (type) {
            if (annotatedTypes.contains(type)) {
                continue;
            }
            try {
                if (type.isPrimitive()) {
                    continue;
                }

                addParametrizedTypes(type, types);

                processConverterAnnotations(type);
                processAliasAnnotation(type, types);
                processAliasTypeAnnotation(type);

                if (type.isInterface()) {
                    continue;
                }

                final Field[] fields = type.getDeclaredFields();
                for (final Field field : fields) {
                    if (field.isEnumConstant()
                        || (field.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) > 0) {
                        continue;
                    }

                    addParametrizedTypes(field.getGenericType(), types);

                    if (field.isSynthetic()) {
                        continue;
                    }

                    processFieldAliasAnnotation(field);
                    processAsAttributeAnnotation(field);
                    processImplicitAnnotation(field);
                    processOmitFieldAnnotation(field);
                    processLocalConverterAnnotation(field);
                }
            } finally {
                annotatedTypes.add(type);
            }
        }
    }
}