/** * Looks for a property with the given name in the map and returns it. <code>null</code> is returned if it is not * found. * * @param name the name of the property to return * * @return the named property or <code>null</code> if it does not exist as a child to this map */ public Property get(String name) { return getMap().get(name); }
/** * This clears the current internal map replaces it with all of the provided map entries. * * @param map the map providing the new mappings */ public void setMap(Map<String, Property> map) { if (this.map == map) { return; } // Don't replace the possible Hibernate proxy when orphanRemoval=true. It can cause // "collection with cascade=all-delete-orphan was no longer referenced" exceptions. this.map = getMap(); this.map.clear(); if (null != map) { this.map.putAll(map); } }
/** * NOTE: An PropertyMap containing a null map is considered equal to a PropertyMap containing an empty map. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || !(obj instanceof PropertyMap)) { return false; } if (!super.equals(obj)) { return false; // superclass checks equality of the name fields } PropertyMap that = (PropertyMap) obj; // NOTE: Use that.getMap(), rather than that.map, in case 'that' is a JPA/Hibernate proxy, to // force loading of the Map. if ((this.map == null) || this.map.isEmpty()) { return (that.getMap() == null) || that.getMap().isEmpty(); } return this.map.equals(that.getMap()); }
@Override protected void appendToStringInternals(StringBuilder str) { super.appendToStringInternals(str); str.append(", map=").append(getMap()); }
public void print(PropertyMap p, int depth) { out.println(indent(depth) + p.getName() + " [" + p.getMap().size() + "] {"); for (String key : p.getMap().keySet()) { Property entry = p.getMap().get(key); if (entry instanceof PropertySimple) { print((PropertySimple) entry, depth + 1); } else if (entry instanceof PropertyMap) { print((PropertyMap) entry, depth + 1); } } out.println(indent(depth) + "}"); }
private String printProperty(Property property) { if (property instanceof PropertySimple) { return ((PropertySimple) property).getStringValue(); } else if (property instanceof PropertyMap) { Map<String, Property> map = ((PropertyMap) property).getMap(); StringBuilder builder = new StringBuilder(); for (Property next : map.values()) { builder.append(printProperty(next)); } return builder.toString(); } return "no preview available"; }
private static Map<String, Object> getInnerMap(PropertyMap propertyMap, PropertyDefinitionMap propertyDefinition, boolean strict) { Map<String, Property> map = propertyMap.getMap(); Map<String,Object> result = new HashMap<String, Object>(map.size()); Set<String> names = map.keySet(); for (String name : names ) { Property property = map.get(name); PropertyDefinition definition = null; if (propertyDefinition != null) { definition = propertyDefinition.get(name); } Object target = convertProperty(property,definition, strict); result.put(name,target); } return result; }
/** * Put a child property into this map keyed on the given property's name. This method also sets the * {@link Property#setParentMap(PropertyMap) parent map} for the child property to make persistence work. * * @param property the property to add to this map. */ public void put(@NotNull Property property) { getMap().put(property.getName(), property); property.setParentMap(this); }
public String getSimpleValue(String name, String defaultValue) { PropertySimple property = (PropertySimple) getMap().get(name); if ((property != null) && (property.getStringValue() != null)) { return property.getStringValue(); } else { return defaultValue; } }
private boolean isUndefined(Property property) { if (null == property) { return true; } if (property instanceof PropertySimple) { return ((PropertySimple) property).getStringValue() == null; } else if (property instanceof PropertyMap) { for (Property p : ((PropertyMap) property).getMap().values()) { if (!isUndefined(p)) { return false; } } return true; } // not sure what to do about lists, just return them, this whole thing is a "best-effort" optimization return false; }
private static void prettyPrintProperty(Property property, int indent) { if (property instanceof PropertyList) { for (int i = 0; i < indent; i++) { System.out.print("\t"); } System.out.println("List Property [" + property.getName() + "]"); for (Property p : ((PropertyList) property).getList()) { prettyPrintProperty(p, indent + 1); } } else if (property instanceof PropertyMap) { for (int i = 0; i < indent; i++) { System.out.print("\t"); } System.out.println("Map Property [" + property.getName() + "]"); for (Property p : ((PropertyMap) property).getMap().values()) { prettyPrintProperty(p, indent + 1); } } else if (property instanceof PropertySimple) { for (int i = 0; i < indent; i++) { System.out.print("\t"); } System.out.println(property.getName() + " = " + ((PropertySimple) property).getStringValue()); } } }
for (Object key : ((PropertyMap) row).getMap().keySet()) { String headerKey = stringValueOf(key); keys.add(headerKey);
if (!propertyMap.getMap().containsKey(memberName)) { FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Map '" + mapName + "' does not contain a member property named '" + memberName + "'."); Property memberProperty = propertyMap.getMap().get(memberName); String memberComponentId = PropertyIdGeneratorUtility.getIdentifier(memberProperty, null, AbstractPropertyBagUIComponentTreeFactory.PANEL_ID_SUFFIX); propertyMap.getMap().remove(memberName);
PropertyMap propertyMap = (PropertyMap) property; PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) propertyDefinition; for (Map.Entry<String,Property> entry : propertyMap.getMap().entrySet()) { Property prop = entry.getValue(); PropertyDefinition definition = propertyDefinitionMap.get(name);
private static void replace(PropertySimple prop) { ObfuscatedPropertySimple replacement = new ObfuscatedPropertySimple(prop); replacement.setParentList(prop.getParentList()); replacement.setParentMap(prop.getParentMap()); replacement.setConfiguration(prop.getConfiguration()); if (prop.getParentList() != null) { List<Property> list = prop.getParentList().getList(); int idx = list.indexOf(prop); list.remove(prop); list.add(idx, replacement); } else if (prop.getParentMap() != null) { Map<String, Property> map = prop.getParentMap().getMap(); replaceInMap(replacement, map); } else { Configuration conf = prop.getConfiguration(); replaceInMap(replacement, conf.getMap()); } }
for (String propertyKey : mapType.getMap().keySet()) { currentOptions.put(propertyKey, ((PropertySimple) mapType.get(propertyKey)).getStringValue());
.getPropertyDefinitionMap(propertyMap.getName()); if (!propertyDefinition.isRequired() && propertyMap.getMap().size() == 0) { isEntryEligible = false; } else {