public PropertyList deepCopy(boolean keepId) { PropertyList copy = new PropertyList(this, keepId); for (Property property : list) { copy.add(property.deepCopy(false)); } return copy; }
public void print(PropertyList p, int depth) { out.println(indent(depth) + p.getName() + " [" + p.getList().size() + "] {"); if (p.getList().size() > 0 && p.getList().get(0) instanceof PropertyMap) { consistentMaps(p.getList()); } else { for (Property entry : p.getList()) { if (entry instanceof PropertySimple) { print((PropertySimple) entry, depth + 1); } else if (entry instanceof PropertyMap) { print((PropertyMap) entry, depth + 1); } } } out.println(indent(depth) + "}"); }
private boolean hasErrors(PropertyList list) { if (list.getErrorMessage() != null) { return true; } for (Property p : list.getList()) { if (hasErrors(p)) { return true; } } return false; }
private static void adaptPropertyList(PropertyList source, PropertyList target, PropertyDefinitionList definition, Object parent, boolean adaptReadonlyProperties) { if ((adaptReadonlyProperties || !definition.isReadOnly())) { if (target == null) { target = new PropertyList(definition.getName()); add(parent, target); } if (target.getList().isEmpty()) { PropertyDefinition memberDef = definition.getMemberDefinition(); for (Property p : source.getList()) { PropertyType type = conforms(p, memberDef); if (type != null && type != PropertyType.UNKNOWN) { Property targetMember = instantiateDefaultProperty(memberDef); target.add(targetMember); adaptProperty(p, targetMember, memberDef, target, adaptReadonlyProperties); } } } } }
/** * Sets the list of child properties directly to the given <code>list</code> reference. This means the actual <code> * list</code> object is stored internally in this object. Changes made to <code>list</code> will be reflected back * into this object. * * <p><b>Warning:</b> Caution should be used when setting this object's internal list. Please see * {@link PropertyList the javadoc for this class} for more information.</p> * * @param list the new list used internally by this object */ public void setList(List<Property> list) { if (list != null) { for (Property property : list) { add(property); } } }
private int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); String mapName = mapDefinition.getName(); PropertyMap newMap = new PropertyMap(mapName); for (PropertyDefinition mapMemberDefinition : mapDefinition.getOrderedPropertyDefinitions()) { PropertyDefinitionSimple simpleDefinition = (PropertyDefinitionSimple) mapMemberDefinition; newMap.put(new PropertySimple(simpleDefinition.getName(), (simpleDefinition.isRequired()) ? "" : null)); } PropertyList list = config.getConfiguration().getList(listName); list.add(newMap); return list.getList().size() - 1; }
/** * 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); }
PropertyDefinitionMap propertyDefinitionMap = (PropertyDefinitionMap) listMemberPropertyDefinition; PropertyList propertyList = parentPropertyMap.getList(propertyDefinition.getName()); for (Property property : propertyList.getList()) { PropertyMap propertyMap = (PropertyMap) property; normalizePropertyMap(propertyMap, propertyDefinitionMap, false, property = new PropertyMap(propertyDefinition.getName()); } else if (propertyDefinition instanceof PropertyDefinitionList) { property = new PropertyList(propertyDefinition.getName()); } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
if (null != currentPropertyList && !currentPropertyList.getList().isEmpty()) { if (!currentPropertyList.equals(propertyList)) { errorMessages.add("ReadOnly property '" + propertyDefinitionList.getName() + "' has a value " + propertyList.getList() + " different than the current value " + currentPropertyList.getList() + "]. It is not allowed to change."); for (Property property : propertyList.getList()) { if (listMemberPropertyDefinition instanceof PropertyDefinitionSimple) { validatePropertySimple(listMemberPropertyDefinition, (PropertySimple) property, null,
private AbstractPropertyListBuilder(String name, String memberName) { this.list = new PropertyList(name); this.list.memberPropertyName = memberName; }
/** * Return a value object for the passed property, which is part of a list. The type is determined by * looking at the operation definition and PropertyList#getMemberDefinition * @param prop Property to evaluate * @param propertyList Outer list * @param operationName Name of the operation * @return Value or null on failure */ Object getObjectForPropertyList(PropertySimple prop, PropertyList propertyList, String operationName) { ConfigurationDefinition parameterDefinitions = getParameterDefinitionsForOperation(operationName); if (parameterDefinitions == null) return null; PropertyDefinition def = parameterDefinitions.get(propertyList.getName()); if (def instanceof PropertyDefinitionList) { PropertyDefinitionList definitionList = (PropertyDefinitionList) def; PropertyDefinition tmp = definitionList.getMemberDefinition(); if (tmp instanceof PropertyDefinitionSimple) { return getObjectForProperty(prop, (PropertyDefinitionSimple) tmp); } } return null; }
switch (refProp.getType()) { case LIST: PropertyList list = pluginConfiguration.getList(refProp.getName()).deepCopy(false); list.setName(refProp.getTargetName()); switch (refProp.getType()) { case LIST: PropertyList list = resourceConfiguration.getList(refProp.getName()).deepCopy(false); list.setName(refProp.getTargetName());
PropertyList seedsList = parameters.getList(SEEDS_LIST).deepCopy(false); Subject subject = getSubject(resourceOperationHistory); performAddNodeMaintenance(subject, nextNode, runRepair, seedsList, newNodeAddress);
/** * Creates a new, empty {@link PropertyList} object that is associated with the given name. * * @param name the name of the list itself */ public PropertyList(@NotNull String name) { setName(name); }
/** * Creates a new {@link PropertyList} object that is associated with the given name and has the given properties as * its initial list of child properties. All properties found in <code>startingList</code> will have their * {@link Property#setParentList(PropertyList) parent list} set to this newly constructed list. * * @param name the name of the list itself * @param startingList a list of properties to be immediately added to this list */ public PropertyList(@NotNull String name, @NotNull Property... startingList) { this(name); for (Property property : startingList) { add(property); } }
PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition; PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition(); PropertyList targetPropertyList = new PropertyList(propertyDefinition.getName()); targetParentPropertyMap.put(targetPropertyList); if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
} else { boolean runRepair = parameters.getSimple(RUN_REPAIR_PROPERTY).getBooleanValue(); PropertyList seedsList = parameters.getList(SEEDS_LIST).deepCopy(false); Subject subject = getSubject(operationHistory); performRemoveNodeMaintenance(subject, nextNode, runRepair, seedsList, removedNodeAddress);
private static PropertyList getPropertyList(String listName, String propertyName, List<? extends Object> objects) { PropertyList propertyList = new PropertyList(listName); for(Object o : objects) { propertyList.add(new PropertySimple(propertyName, o)); } return propertyList; }
@Override boolean isConnectorPropertyDefined() { PropertyList staticConnectors = configuration.getList(STATIC_CONNECTORS_PROPERTY); return staticConnectors != null && !staticConnectors.getList().isEmpty(); }