List of usage examples for java.util Collections EMPTY_MAP
Map EMPTY_MAP
To view the source code for java.util Collections EMPTY_MAP.
Click Source Link
From source file:org.codehaus.groovy.grails.plugins.web.api.ControllersApi.java
public Object bindData(Object instance, Object target, Object bindingSource, String filter) { return bindData(instance, target, bindingSource, Collections.EMPTY_MAP, filter); }
From source file:org.alfresco.module.org_alfresco_module_rm.report.generator.DeclarativeReportGenerator.java
/** * @see org.alfresco.module.org_alfresco_module_rm.report.generator.BaseReportGenerator#generateReportMetadata(org.alfresco.service.cmr.repository.NodeRef) *///from www . j a va2s . c om @SuppressWarnings("unchecked") @Override protected Map<QName, Serializable> generateReportMetadata(NodeRef reportedUponNodeRef) { return Collections.EMPTY_MAP; }
From source file:org.codehaus.groovy.grails.plugins.web.api.ControllersApi.java
public Object bindData(Object instance, Object target, Object bindingSource) { return bindData(instance, target, bindingSource, Collections.EMPTY_MAP, null); }
From source file:org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingsHolder.java
@Override public UrlCreator getReverseMappingNoDefault(String controller, String action, String namespace, String pluginName, String httpMethod, String version, Map params) { if (params == null) params = Collections.EMPTY_MAP; if (urlCreatorCache != null) { UrlCreatorCache.ReverseMappingKey key = urlCreatorCache.createKey(controller, action, namespace, pluginName, httpMethod, params); UrlCreator creator = urlCreatorCache.lookup(key); if (creator == null) { creator = resolveUrlCreator(controller, action, namespace, pluginName, httpMethod, version, params, false);//from w ww .j a v a 2 s . c o m if (creator != null) { creator = urlCreatorCache.putAndDecorate(key, creator); } } // preserve previous side-effect, remove mappingName from params params.remove("mappingName"); return creator; } // cache is disabled return resolveUrlCreator(controller, action, namespace, pluginName, httpMethod, version, params, true); }
From source file:com.facebook.litho.DebugComponent.java
/** * @return Key-value mapping of this components props. *///from w w w.ja v a 2 s .com public Map<String, Pair<Prop, Object>> getProps() { final InternalNode node = mNode.get(); final Component component = node == null || node.getComponents().isEmpty() ? null : node.getComponents().get(mComponentIndex); if (component == null) { return Collections.EMPTY_MAP; } final Map<String, Pair<Prop, Object>> props = new ArrayMap<>(); final ComponentLifecycle.StateContainer stateContainer = component.getStateContainer(); for (Field field : component.getClass().getDeclaredFields()) { try { field.setAccessible(true); final Prop propAnnotation = field.getAnnotation(Prop.class); if (propAnnotation != null) { final Object value = field.get(component); if (value != stateContainer && !(value instanceof ComponentLifecycle)) { props.put(field.getName(), new Pair<>(propAnnotation, value)); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } return props; }
From source file:edu.uci.ics.jung.io.GraphMLWriter.java
/** * Adds a new edge data specification.//from w ww . java 2 s . com */ public void addEdgeData(String id, String description, String default_value, Transformer<E, String> edge_transformer) { if (edge_data.equals(Collections.EMPTY_MAP)) edge_data = new HashMap<String, GraphMLMetadata<E>>(); edge_data.put(id, new GraphMLMetadata<E>(description, default_value, edge_transformer)); }
From source file:org.apache.cayenne.access.ObjectStore.java
/** * Evicts a collection of DataObjects from the ObjectStore, invalidates the underlying * cache snapshots. Changes objects state to TRANSIENT. This method can be used for * manual cleanup of Cayenne cache./*from w w w .j a va2s . c o m*/ */ // this method is exactly the same as "objectsInvalidated", only additionally it // throws out registered objects public synchronized void objectsUnregistered(Collection objects) { if (objects.isEmpty()) { return; } Collection<ObjectId> ids = new ArrayList<ObjectId>(objects.size()); Iterator it = objects.iterator(); while (it.hasNext()) { Persistent object = (Persistent) it.next(); ObjectId id = object.getObjectId(); // remove object but not snapshot objectMap.remove(id); changes.remove(id); ids.add(id); object.setObjectContext(null); object.setObjectId(null); object.setPersistenceState(PersistenceState.TRANSIENT); } // TODO, andrus 3/28/2006 - DRC is null in nested contexts... implement // propagation of unregister operation through the stack ... or do the opposite // and keep unregister local even for non-nested DC? if (getDataRowCache() != null) { // send an event for removed snapshots getDataRowCache().processSnapshotChanges(this, Collections.EMPTY_MAP, Collections.EMPTY_LIST, ids, Collections.EMPTY_LIST); } }
From source file:com.xwtec.xwserver.util.json.JSONObject.java
/** * Creates a bean from a JSONObject, with the specific configuration. *//* w w w. j av a 2s. co m*/ public static Object toBean(JSONObject jsonObject, JsonConfig jsonConfig) { if (jsonObject == null || jsonObject.isNullObject()) { return null; } Class beanClass = jsonConfig.getRootClass(); Map classMap = jsonConfig.getClassMap(); if (beanClass == null) { return toBean(jsonObject); } if (classMap == null) { classMap = Collections.EMPTY_MAP; } Object bean = null; try { if (beanClass.isInterface()) { if (!Map.class.isAssignableFrom(beanClass)) { throw new JSONException("beanClass is an interface. " + beanClass); } else { bean = new HashMap(); } } else { bean = jsonConfig.getNewBeanInstanceStrategy().newInstance(beanClass, jsonObject); } } catch (JSONException jsone) { throw jsone; } catch (Exception e) { throw new JSONException(e); } Map props = JSONUtils.getProperties(jsonObject); PropertyFilter javaPropertyFilter = jsonConfig.getJavaPropertyFilter(); for (Iterator entries = jsonObject.names(jsonConfig).iterator(); entries.hasNext();) { String name = (String) entries.next(); Class type = (Class) props.get(name); Object value = jsonObject.get(name); if (javaPropertyFilter != null && javaPropertyFilter.apply(bean, name, value)) { continue; } String key = Map.class.isAssignableFrom(beanClass) && jsonConfig.isSkipJavaIdentifierTransformationInMapKeys() ? name : JSONUtils.convertToJavaIdentifier(name, jsonConfig); PropertyNameProcessor propertyNameProcessor = jsonConfig.findJavaPropertyNameProcessor(beanClass); if (propertyNameProcessor != null) { key = propertyNameProcessor.processPropertyName(beanClass, key); } try { if (Map.class.isAssignableFrom(beanClass)) { // no type info available for conversion if (JSONUtils.isNull(value)) { setProperty(bean, key, value, jsonConfig); } else if (value instanceof JSONArray) { setProperty(bean, key, convertPropertyValueToCollection(key, value, jsonConfig, name, classMap, List.class), jsonConfig); } else if (String.class.isAssignableFrom(type) || JSONUtils.isBoolean(type) || JSONUtils.isNumber(type) || JSONUtils.isString(type) || JSONFunction.class.isAssignableFrom(type)) { if (jsonConfig.isHandleJettisonEmptyElement() && "".equals(value)) { setProperty(bean, key, null, jsonConfig); } else { setProperty(bean, key, value, jsonConfig); } } else { Class targetClass = findTargetClass(key, classMap); targetClass = targetClass == null ? findTargetClass(name, classMap) : targetClass; JsonConfig jsc = jsonConfig.copy(); jsc.setRootClass(targetClass); jsc.setClassMap(classMap); if (targetClass != null) { setProperty(bean, key, toBean((JSONObject) value, jsc), jsonConfig); } else { setProperty(bean, key, toBean((JSONObject) value), jsonConfig); } } } else { PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(bean, key); if (pd != null && pd.getWriteMethod() == null) { log.info("Property '" + key + "' of " + bean.getClass() + " has no write method. SKIPPED."); continue; } if (pd != null) { Class targetType = pd.getPropertyType(); if (!JSONUtils.isNull(value)) { if (value instanceof JSONArray) { if (List.class.isAssignableFrom(pd.getPropertyType())) { setProperty(bean, key, convertPropertyValueToCollection(key, value, jsonConfig, name, classMap, pd.getPropertyType()), jsonConfig); } else if (Set.class.isAssignableFrom(pd.getPropertyType())) { setProperty(bean, key, convertPropertyValueToCollection(key, value, jsonConfig, name, classMap, pd.getPropertyType()), jsonConfig); } else { setProperty(bean, key, convertPropertyValueToArray(key, value, targetType, jsonConfig, classMap), jsonConfig); } } else if (String.class.isAssignableFrom(type) || JSONUtils.isBoolean(type) || JSONUtils.isNumber(type) || JSONUtils.isString(type) || JSONFunction.class.isAssignableFrom(type)) { if (pd != null) { if (jsonConfig.isHandleJettisonEmptyElement() && "".equals(value)) { setProperty(bean, key, null, jsonConfig); } else if (!targetType.isInstance(value)) { setProperty(bean, key, morphPropertyValue(key, value, type, targetType), jsonConfig); } else { setProperty(bean, key, value, jsonConfig); } } else if (beanClass == null || bean instanceof Map) { setProperty(bean, key, value, jsonConfig); } else { log.warn("Tried to assign property " + key + ":" + type.getName() + " to bean of class " + bean.getClass().getName()); } } else { if (jsonConfig.isHandleJettisonSingleElementArray()) { JSONArray array = new JSONArray().element(value, jsonConfig); Class newTargetClass = findTargetClass(key, classMap); newTargetClass = newTargetClass == null ? findTargetClass(name, classMap) : newTargetClass; JsonConfig jsc = jsonConfig.copy(); jsc.setRootClass(newTargetClass); jsc.setClassMap(classMap); if (targetType.isArray()) { setProperty(bean, key, JSONArray.toArray(array, jsc), jsonConfig); } else if (JSONArray.class.isAssignableFrom(targetType)) { setProperty(bean, key, array, jsonConfig); } else if (List.class.isAssignableFrom(targetType) || Set.class.isAssignableFrom(targetType)) { jsc.setCollectionType(targetType); setProperty(bean, key, JSONArray.toCollection(array, jsc), jsonConfig); } else { setProperty(bean, key, toBean((JSONObject) value, jsc), jsonConfig); } } else { if (targetType == Object.class || targetType.isInterface()) { Class targetTypeCopy = targetType; targetType = findTargetClass(key, classMap); targetType = targetType == null ? findTargetClass(name, classMap) : targetType; targetType = targetType == null && targetTypeCopy.isInterface() ? targetTypeCopy : targetType; } JsonConfig jsc = jsonConfig.copy(); jsc.setRootClass(targetType); jsc.setClassMap(classMap); setProperty(bean, key, toBean((JSONObject) value, jsc), jsonConfig); } } } else { if (type.isPrimitive()) { // assume assigned default value log.warn("Tried to assign null value to " + key + ":" + type.getName()); setProperty(bean, key, JSONUtils.getMorpherRegistry().morph(type, null), jsonConfig); } else { setProperty(bean, key, null, jsonConfig); } } } else { // pd is null if (!JSONUtils.isNull(value)) { if (value instanceof JSONArray) { setProperty(bean, key, convertPropertyValueToCollection(key, value, jsonConfig, name, classMap, List.class), jsonConfig); } else if (String.class.isAssignableFrom(type) || JSONUtils.isBoolean(type) || JSONUtils.isNumber(type) || JSONUtils.isString(type) || JSONFunction.class.isAssignableFrom(type)) { if (beanClass == null || bean instanceof Map || jsonConfig.getPropertySetStrategy() != null || !jsonConfig.isIgnorePublicFields()) { setProperty(bean, key, value, jsonConfig); } else { log.warn("Tried to assign property " + key + ":" + type.getName() + " to bean of class " + bean.getClass().getName()); } } else { if (jsonConfig.isHandleJettisonSingleElementArray()) { Class newTargetClass = findTargetClass(key, classMap); newTargetClass = newTargetClass == null ? findTargetClass(name, classMap) : newTargetClass; JsonConfig jsc = jsonConfig.copy(); jsc.setRootClass(newTargetClass); jsc.setClassMap(classMap); setProperty(bean, key, toBean((JSONObject) value, jsc), jsonConfig); } else { setProperty(bean, key, value, jsonConfig); } } } else { if (type.isPrimitive()) { // assume assigned default value log.warn("Tried to assign null value to " + key + ":" + type.getName()); setProperty(bean, key, JSONUtils.getMorpherRegistry().morph(type, null), jsonConfig); } else { setProperty(bean, key, null, jsonConfig); } } } } } catch (JSONException jsone) { throw jsone; } catch (Exception e) { throw new JSONException("Error while setting property=" + name + " type " + type, e); } } return bean; }
From source file:net.lightbody.bmp.proxy.jetty.util.URI.java
/** Get the uri query _parameters. * @return the URI query _parameters in an unmodifiable map. *//*from w w w. ja v a 2 s . co m*/ public Map getUnmodifiableParameters() { if (_parameters == null) return Collections.EMPTY_MAP; return Collections.unmodifiableMap(_parameters); }
From source file:org.terasoluna.gfw.web.el.ObjectToMapConverterTest.java
@SuppressWarnings("unchecked") @Test//w w w . j ava 2 s . co m public void test7_Null() { assertThat(converter.convert(null), is((Map<String, String>) Collections.EMPTY_MAP)); }