public PropertyMap deepCopy(boolean keepId) { PropertyMap copy = new PropertyMap(this, keepId); for (Property property : map.values()) { copy.put(property.deepCopy(keepId)); } return copy; }
/** * Looks for a child map 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 child map property to return * * @return the named map property or <code>null</code> if it does not exist as a child to this map * * @throws ClassCastException if the named property is not of type {@link PropertyMap} */ public PropertyMap getMap(String name) { return (PropertyMap) get(name); }
/** * 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); }
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) + "}"); }
PropertySimple findOverrideForMetric(MetricTemplate def, PropertyList overrides) { for (Property p : overrides.getList()) { PropertyMap map = (PropertyMap) p; String metricName = map.getSimpleValue(METRIC_NAME_PROPERTY, null); String resourceTypeName = map.getSimpleValue(RESOURCE_TYPE_NAME_PROPERTY, null); String resourceTypePlugin = map.getSimpleValue(RESOURCE_TYPE_PLUGIN_PROPERTY, null); PropertySimple updateSchedules = map.getSimple(UPDATE_SCHEDULES_PROPERTY); if (metricName == null || resourceTypeName == null || resourceTypePlugin == null || updateSchedules == null) { continue; } if (metricName.equals(def.getMetricName()) && resourceTypeName.equals(def.getResourceTypeName()) && resourceTypePlugin.equals(def.getResourceTypePlugin())) { return updateSchedules; } } return null; } }
public MapInList(Parent parent, String name) { super(new PropertyMap(name)); this.parent = parent; }
private List<String> getLogFilePaths(List<PropertyMap> enabledEventSources) { List<String> logFilePaths = new ArrayList<String>(enabledEventSources.size()); for (PropertyMap logEventSource : enabledEventSources) { String logFilePath = logEventSource.getSimpleValue(LogEventSourcePropertyNames.LOG_FILE_PATH, null); if (logFilePath == null) { throw new IllegalStateException("Required property [" + LogEventSourcePropertyNames.LOG_FILE_PATH + "] is not defined in map."); } logFilePaths.add(logFilePath); } return logFilePaths; } }
/** * Creates a new {@link PropertyMap} object that is associated with the given name and has the given properties as * its initial set of child properties. All properties found in <code>startingProperties</code> will have their * {@link Property#setParentMap(PropertyMap) parent map} set to this newly constructed map. * * @param name the name of the map itself * @param startingProperties a set of properties to be immediately added to this map */ public PropertyMap(@NotNull String name, Property... startingProperties) { this(name); for (Property property : startingProperties) { put(property); } }
if (LOGICAL_REMOVED.equals(prop.getErrorMessage())) return; if (prop.get(namePropLocator) == null) { throw new IllegalArgumentException("There is no element in the map with the name " + namePropLocator); String key = ((PropertySimple) prop.get(namePropLocator)).getStringValue();
@Override public void updateResourceConfiguration(ConfigurationUpdateReport report) { // We need to filter the path properties that are marked with the read-only flag // This is done by setting the logical removed flag on the map to signal // the write delegate to skip the map Configuration config = report.getConfiguration(); PropertyList propertyList = config.getList("*3"); for (Property property : propertyList.getList()) { PropertyMap map = (PropertyMap) property; String ro = map.getSimpleValue("read-only", "false"); if (Boolean.parseBoolean(ro)) { map.setErrorMessage(ConfigurationWriteDelegate.LOGICAL_REMOVED); } } super.updateResourceConfiguration(report); }
private static <T extends BundleDestinationSpecification> T from(PropertyMap map, Class<T> expectedClass) { String name = map.getSimpleValue(BUNDLE_DEST_NAME_NAME, null); String valueContext = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_VALUE_CONTEXT_NAME, null); String description = map.getSimpleValue(BUNDLE_DEST_DESCRIPTION_NAME, null); String connection = map.getSimpleValue(BUNDLE_DEST_DEFINITION_CONNECTION_NAME, null); PropertyList refs = map.getList(BUNDLE_DEST_DEFINITION_REF_LIST_NAME); PropertyList acceptProps = map.getList(BUNDLE_DEST_ACCEPTS_LIST_NAME); BundleDestinationBaseDirectory.class) || expectedClass.equals(BundleDestinationSpecification.class))) { String valueName = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_VALUE_NAME_NAME, null); PropertyMap ref = (PropertyMap) p; String type = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_TYPE_NAME, null); if (type == null) { continue; BundleDestinationDefinition.ConfigRef.Type.valueOf(type); String context = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_CONTEXT_NAME, null); if (context == null) { continue; String refName = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_NAME_NAME, null); if (name == null) { continue; String refTargetName = ref.getSimpleValue(BUNDLE_DEST_DEF_REF_TARGET_NAME_NAME, refName);
for (Property prop2 : pl.getList()) { PropertyMap propMap2 = (PropertyMap) prop2; String itemName = propMap2.getSimple(namePropLocator).getStringValue(); if (itemName == null) { throw new IllegalArgumentException("Map contains no entry with name [" + namePropLocator + "]"); for (Property prop2 : pl.getList()) { PropertyMap propMap2 = (PropertyMap) prop2; String itemName = propMap2.getSimple(namePropLocator).getStringValue(); String errorMessage = propMap2.getErrorMessage(); boolean contains = existingPropnames.contains(itemName); if (!contains && LOGICAL_REMOVED.equals(errorMessage)) {
protected AugeasNode getExistingChildNodeForListMemberPropertyMap(AugeasNode parentNode, PropertyDefinitionList propDefList, PropertyMap propMap) { String mapKey = getListMemberMapKey(propDefList); if (mapKey != null) { String existingChildNodeName = propMap.getSimple(mapKey).getStringValue(); AugeasNode existingChildNode = new AugeasNode(parentNode, existingChildNodeName); return (this.augeas.exists(existingChildNode.getPath())) ? existingChildNode : null; } else { return null; } }
/** * Map property parsing. * * @param property raw map property * @param propertyDefinition property definition * @return otherwise the parsed map, note that the map can be empty if no map properties were set */ protected SimpleEntry<String, Map<String, Object>> preparePropertyMap(PropertyMap property, PropertyDefinitionMap propertyDefinition) { Map<String, Object> results; String propName = stripNumberIdentifier(property.getName()); if (propName.endsWith(":collapsed")) { propName = propName.substring(0, propName.indexOf(':')); results = prepareCollapsedPropertyMap(property, propertyDefinition); } else { results = prepareSimplePropertyMap(property, propertyDefinition); } return new SimpleEntry<String, Map<String, Object>>(propName, results); }
private MapInMap(Parent parent, String name) { super(new PropertyMap(name)); this.parent = parent; }
static Map<String, String> getConnectionPropertiesAsMap(PropertyList listPropertyWrapper, String keyName) { if (listPropertyWrapper == null) { return Collections.emptyMap(); } List<Property> propertyList = listPropertyWrapper.getList(); if (propertyList.size() == 0) { return Collections.emptyMap(); } Map<String, String> result = new HashMap<String, String>(propertyList.size()); for (Property p : propertyList) { PropertyMap map = (PropertyMap) p; String key = map.getSimpleValue(keyName, null); String value = map.getSimpleValue("value", null); if (key == null || value == null) { continue; } result.put(key, value); } return result; } }
private void addAttributeToPropertyMap(String attributeName, PropertyMap propertyMap, Map<String, String> queryCacheAttributes) { propertyMap.put(new PropertySimple(attributeName, queryCacheAttributes.get(attributeName))); } }
for (Property p : sgConfig.getList("*1").getList()) { PropertyMap map = (PropertyMap) p; assignedCurrent.put(map.getSimpleValue("server-group", null), map); PropertyMap duplicate = assignedNew.put(mapNew.getSimpleValue("server-group", null), mapNew); if (duplicate != null) { report.setStatus(ConfigurationUpdateStatus.FAILURE); report.setErrorMessage("Duplicate assignment to [" + duplicate.getSimpleValue("server-group", null) + "] you cannot assign deployment to server-group more than once"); return; String key = mapNew.getSimpleValue("server-group", null); String runtimeNew = mapNew.getSimpleValue("runtime-name", null); boolean enabledNew = mapNew.getSimple("enabled").getBooleanValue(); PropertyMap mapCurrent = assignedCurrent.remove(key); if (mapCurrent == null) { needDiscovery = true; } else { boolean enabledCurrent = mapCurrent.getSimple("enabled").getBooleanValue(); if (enabledCurrent != enabledNew) { operation.addStep(createServerGroupAssignmentStep("remove", map.getSimpleValue("server-group", null), null, false));