private void createDeepCopyOfProperties(Configuration copy, boolean keepId) { for (Property property : this.properties.values()) { copy.put(property.deepCopy(keepId)); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || !(obj instanceof PropertySimple)) { return false; } if (!super.equals(obj)) { return false; // superclass checks equality of the name fields } PropertySimple that = (PropertySimple) obj; // Treat empty string as if it were null See JBNADM-2715 String compareToA = ((this.stringValue != null) && (this.stringValue.length() == 0)) ? null : this.stringValue; String compareToB = ((that.stringValue != null) && (that.stringValue.length() == 0)) ? null : that.stringValue; if ((compareToA != null) ? (!compareToA.equals(compareToB)) : (compareToB != null)) { return false; } return true; }
@Override public String toString() { StringBuilder str = new StringBuilder(this.getClass().getName().substring( this.getClass().getName().lastIndexOf(".") + 1)); str.append("[id=").append(getId()); str.append(", name=").append(getName()); appendToStringInternals(str); // ask subclasses if they have anything else to add str.append(']'); return str.toString(); }
/** * 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); }
/** * Adds the given property to this Configuration object. The property can be a * {@link PropertySimple simple property}, a {@link PropertyList list of properties} or a * {@link PropertyMap map of properties}. * * @param value the new property */ @Override public void put(Property value) { Map<String, Property> map = getMap(); if (value.getName()!=null) { map.put(value.getName().intern(),value); } else { map.put(value.getName(), value); } value.setConfiguration(this); }
case FULL: for (Property p : pluginConfiguration.getProperties()) { Property copy = p.deepCopy(false); if (refProp.getTargetName() != null) { copy.setName(refProp.getTargetName() + copy.getName()); case FULL: for (Property p : resourceConfiguration.getProperties()) { Property copy = p.deepCopy(false); if (refProp.getTargetName() != null) { copy.setName(refProp.getTargetName() + copy.getName());
Configuration configuration = propertyHierarchy.getFirst().getConfiguration(); identifier.append(ID_DELIMITER).append(propertyNode.getName().hashCode()); if (propertyNode.getParentList() != null) { if (index == null) { throw new IllegalStateException("Property " + property
/** * Adds a child property to the end of this list. This method also sets the * {@link Property#setParentList(PropertyList) parent list} for the child property to make persistence work. * * @param property the property to add to this list */ public void add(@NotNull Property property) { if (this.memberPropertyName == null) { this.memberPropertyName = property.getName(); } if (!property.getName().equals(this.memberPropertyName)) { throw new IllegalStateException("All properties in a PropertyList (id=[" + getId() + "], name=[" + getName() + "]) must have the same name: [" + property.getName() + "] != [" + this.memberPropertyName + "]"); } getList().add(property); property.setParentList(this); }
@Override @Lock(LockType.WRITE) public void unsetUserProperty(int subjectId, String propertyName) { load(subjectId); Configuration config = subjectPreferences.get(subjectId); if (config == null) { return; } Property property = config.remove(propertyName); // it's possible property was already removed, and thus this operation becomes a no-op to the backing store if (property != null && property.getId() != 0) { try { configurationManager.deleteProperties(new int[] { property.getId() }); } catch (Throwable t) { log.error("Could not remove " + property, t); } } }
@Override protected void appendToStringInternals(StringBuilder str) { super.appendToStringInternals(str); str.append(", map=").append(getMap()); }
@Override protected void appendToStringInternals(StringBuilder str) { super.appendToStringInternals(str); str.append(", list=").append(getList()); }
/** * Returns a map of all <i>direct</i> children of this Configuration that are of type {@link PropertyMap}. The * returned map is keyed on the {@link PropertyMap}'s names. * * @return map containing of all of the Configuration's direct {@link PropertyMap} children */ @NotNull public Map<String, PropertyMap> getMapProperties() { Map<String, PropertyMap> map = new LinkedHashMap<String, PropertyMap>(); for (Property prop : this.getProperties()) { if (prop instanceof PropertyMap) { map.put(prop.getName(), (PropertyMap) prop); } } return map; }
public PropertyMap deepCopy(boolean keepId) { PropertyMap copy = new PropertyMap(this, keepId); for (Property property : map.values()) { copy.put(property.deepCopy(keepId)); } return copy; }
/** * 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(", value=").append(getStringValue()); str.append(", override=").append(getOverride()); } }
/** * Returns a map of all <i>direct</i> children of this Configuration that are of type {@link PropertySimple}. The * returned map is keyed on the {@link PropertySimple}'s names. * * @return map containing of all of the Configuration's direct {@link PropertySimple} children */ @NotNull public Map<String, PropertySimple> getSimpleProperties() { Map<String, PropertySimple> map = new LinkedHashMap<String, PropertySimple>(); for (Property prop : this.getProperties()) { if (prop instanceof PropertySimple) { map.put(prop.getName(), (PropertySimple) prop); } } return map; }
public PropertyList deepCopy(boolean keepId) { PropertyList copy = new PropertyList(this, keepId); for (Property property : list) { copy.add(property.deepCopy(false)); } return copy; }