List of usage examples for java.lang Enum name
String name
To view the source code for java.lang Enum name.
Click Source Link
From source file:com.evolveum.midpoint.gui.api.component.BasePanel.java
public StringResourceModel createStringResource(Enum e, String prefix, String nullKey) { StringBuilder sb = new StringBuilder(); if (StringUtils.isNotEmpty(prefix)) { sb.append(prefix).append('.'); }/*from www . j ava 2 s . com*/ if (e == null) { if (StringUtils.isNotEmpty(nullKey)) { sb.append(nullKey); } else { sb = new StringBuilder(); } } else { sb.append(e.getDeclaringClass().getSimpleName()).append('.'); sb.append(e.name()); } return createStringResource(sb.toString()); }
From source file:com.evolveum.midpoint.repo.sql.query.restriction.ItemRestriction.java
private Enum getRepoEnumValue(Enum schemaValue, Class repoType) throws QueryException { if (schemaValue == null) { return null; }// www .java 2s. com if (SchemaEnum.class.isAssignableFrom(repoType)) { return (Enum) RUtil.getRepoEnumValue(schemaValue, repoType); } Object[] constants = repoType.getEnumConstants(); for (Object constant : constants) { Enum e = (Enum) constant; if (e.name().equals(schemaValue.name())) { return e; } } throw new QueryException( "Unknown enum value '" + schemaValue + "', which is type of '" + schemaValue.getClass() + "'."); }
From source file:org.waarp.common.json.AdaptativeJsonHandler.java
/** * //from w w w. ja v a2s . c o m * @param node * @param field * @param value */ public final void setValue(ObjectNode node, Enum<?> field, String value) { if (value == null || value.isEmpty()) { return; } node.put(field.name(), value); }
From source file:org.waarp.common.json.AdaptativeJsonHandler.java
/** * /*from w w w .j a v a 2s .c o m*/ * @param node * @param field * @param value */ public final void setValue(ObjectNode node, Enum<?> field, byte[] value) { if (value == null || value.length == 0) { return; } node.put(field.name(), value); }
From source file:com.googlecode.jsonplugin.JSONWriter.java
/** * Instrospect an Enum and serialize it as a name/value pair or as a bean including all its own properties *///from w ww . j av a2s . c o m private void enumeration(Enum enumeration) throws JSONException { if (enumAsBean) { this.bean(enumeration); } else { this.string(enumeration.name()); } }
From source file:org.structr.core.graph.IndexNodeCommand.java
private void init() { if (!initialized) { for (Enum indexName : (NodeIndex[]) arguments.get("indices")) { indices.put(indexName.name(), (Index<Node>) arguments.get(indexName.name())); }/* w ww . ja va 2s.c om*/ initialized = true; } }
From source file:org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigHadoopLogger.java
@Override @SuppressWarnings("rawtypes") public void warn(Object o, String msg, Enum warningEnum) { String className = o.getClass().getName(); String displayMessage = className + "(" + warningEnum + "): " + msg; if (getAggregate()) { if (reporter != null) { // log at least once if (msgMap.get(o) == null || !msgMap.get(o).equals(displayMessage)) { log.warn(displayMessage); msgMap.put(o, displayMessage); }/*from w ww .j a v a 2 s. c o m*/ if (o instanceof EvalFunc || o instanceof LoadFunc || o instanceof StoreFunc) { reporter.incrCounter(className, warningEnum.name(), 1); } // For backwards compatibility, always report with warningEnum, see PIG-3739 reporter.incrCounter(warningEnum, 1); } else { //TODO: //in local mode of execution if the PigHadoopLogger is used initially, //then aggregation cannot be performed as the reporter will be null. //The reference to a reporter is given by Hadoop at run time. //In local mode, due to the absence of Hadoop there will be no reporter //Just print the warning message as is. //If a warning message is printed in map reduce mode when aggregation //is turned on then we have a problem, its a bug. log.warn(displayMessage); } } else { log.warn(displayMessage); } }
From source file:org.rhq.scripting.javascript.JavascriptCompletor.java
/** * Look through all available contexts to find bindings that both start with * the supplied start and match the typeFilter. * @param start//from w ww.jav a2 s . c o m * @param typeFilter * @return */ private Map<String, Object> getContextMatches(String start, Class<?> typeFilter) { Map<String, Object> found = new HashMap<String, Object>(); if (context != null) { for (int scope : context.getScopes()) { Bindings bindings = context.getBindings(scope); for (String var : bindings.keySet()) { if (var.startsWith(start)) { if ((bindings.get(var) != null && typeFilter.isAssignableFrom(bindings.get(var).getClass())) || recomplete == 3) { found.put(var, bindings.get(var)); } } } } if (typeFilter.isEnum()) { for (Object ec : typeFilter.getEnumConstants()) { Enum<?> e = (Enum<?>) ec; String code = typeFilter.getSimpleName() + "." + e.name(); if (code.startsWith(start)) { found.put(typeFilter.getSimpleName() + "." + e.name(), e); } } } } return found; }
From source file:org.structr.core.EntityContext.java
/** * Initialize the entity context for the given class. * This method sets defaults common for any class, f.e. registers any of its parent properties. * * @param type//from w w w . j a v a 2s . c o m */ public static void init(Class type) { // 1. Register searchable keys of superclasses for (Enum index : NodeService.NodeIndex.values()) { String indexName = index.name(); Map<String, Set<PropertyKey>> searchablePropertyMapForType = getSearchablePropertyMapForType(type); Set<PropertyKey> searchablePropertySet = searchablePropertyMapForType.get(indexName); if (searchablePropertySet == null) { searchablePropertySet = new LinkedHashSet<PropertyKey>(); searchablePropertyMapForType.put(indexName, searchablePropertySet); } Class localType = type.getSuperclass(); while ((localType != null) && !localType.equals(Object.class)) { Set<PropertyKey> superProperties = getSearchableProperties(localType, indexName); searchablePropertySet.addAll(superProperties); // include property sets from interfaces for (Class interfaceClass : getInterfacesForType(localType)) { searchablePropertySet.addAll(getSearchableProperties(interfaceClass, indexName)); } // one level up :) localType = localType.getSuperclass(); } } }
From source file:com.jhkt.playgroundArena.db.nosql.mongodb.beans.AbstractDocument.java
public final BasicDBObject resolveToBasicDBObject() { BasicDBObject bDBObject = new BasicDBObject(); try {/*from w w w . j av a 2s. c om*/ Class<? extends AbstractDocument> currClass = getClass(); while (currClass != null) { for (Method method : currClass.getMethods()) { IDocumentKeyValue dkv = method.getAnnotation(IDocumentKeyValue.class); String mName = method.getName(); if (dkv != null && mName.startsWith(JPAConstants.GETTER_PREFIX)) { try { Object returnValue = method.invoke(this, JPAConstants.EMPTY_OBJECT_ARGUMENT_LIST); char[] propertyChars = mName.substring(3).toCharArray(); String property = String.valueOf(propertyChars[0]).toLowerCase() + String.valueOf(propertyChars, 1, propertyChars.length - 1); if (returnValue == null) { continue; } if (returnValue instanceof AbstractDocument) { Object subReturnValue = RESOLVE_TO_BASIC_DB_OBJECT_METHOD.invoke(returnValue, JPAConstants.EMPTY_OBJECT_ARGUMENT_LIST); bDBObject.put(property, subReturnValue); } else if (returnValue instanceof Enum) { Enum<?> enumClass = Enum.class.cast(returnValue); BasicDBObject enumObject = new BasicDBObject(); enumObject.put(JPAConstants.CONVERTER_CLASS.CLASS.name(), enumClass.getClass().getName()); enumObject.put(JPAConstants.CONVERTER_CLASS.CONTENT.name(), enumClass.name()); bDBObject.put(property, enumObject); } else if (returnValue instanceof Collection) { Collection<?> collectionContent = (Collection<?>) returnValue; BasicDBObject collectionObject = new BasicDBObject(); collectionObject.put(JPAConstants.CONVERTER_CLASS.CLASS.name(), collectionContent.getClass().getName()); BasicDBList bDBList = new BasicDBList(); if (collectionContent.iterator().next() instanceof AbstractDocument) { for (Object content : collectionContent) { if (content instanceof AbstractDocument) { Object subReturnValue = RESOLVE_TO_BASIC_DB_OBJECT_METHOD .invoke(returnValue, JPAConstants.EMPTY_OBJECT_ARGUMENT_LIST); bDBList.add(subReturnValue); } } } else { bDBList.addAll(collectionContent); } collectionObject.put(JPAConstants.CONVERTER_CLASS.CONTENT.name(), bDBList); bDBObject.put(property, collectionObject); } else if (returnValue instanceof Map) { Map<?, ?> mapContent = (Map<?, ?>) returnValue; BasicDBObject mapObject = new BasicDBObject(); mapObject.put(JPAConstants.CONVERTER_CLASS.CLASS.name(), mapContent.getClass().getName()); Set<?> keys = mapContent.keySet(); if (keys.iterator().next() instanceof AbstractDocument) { Map<Object, Object> convertedMap = new HashMap<Object, Object>(); for (Object key : keys) { Object value = mapContent.get(key); Object subReturnValue = RESOLVE_TO_BASIC_DB_OBJECT_METHOD.invoke(value, JPAConstants.EMPTY_OBJECT_ARGUMENT_LIST); convertedMap.put(key, subReturnValue); } mapContent = convertedMap; } mapObject.put(JPAConstants.CONVERTER_CLASS.CONTENT.name(), mapContent); bDBObject.put(property, mapObject); } else { bDBObject.put(property, returnValue); } } catch (Exception e) { } } } currClass = currClass.getSuperclass().asSubclass(AbstractDocument.class); } } catch (ClassCastException castException) { } bDBObject.put(JPAConstants.CONVERTER_CLASS.CLASS.name(), getClass().getName()); _log.info("BdBObject " + bDBObject); return bDBObject; }