private void removeConfiguration() { if (!isNew()) { pluginElement.removeChild("properties"); } configuration = null; }
/** * Sets configuration property value as {@literal <name>value</name>}. * * <p>If element doesn't have configuration element it will be created as well. <b>Note: it should * not be used with nested configuration elements</b> * * @param name property name to set * @param value property value to set * @return this plugin instance * @throws NullPointerException when {@code name} or {@code value} is {@code null} */ public Plugin setConfigProperty(String name, String value) { requireNonNull(name, "Configuration property name should not be null"); requireNonNull(value, "Configuration property value should not be null"); if (!isNew()) { addConfigPropertyToXML(name, value); } configuration().put(name, value); return this; }
/** * Removes configuration property. If configuration has nested element with removal {@code name} * it will be removed with all related children. * * @param name configuration property which indicated element that should be removed * @return this plugin instance * @throws NullPointerException when {@code name} is null */ public Plugin removeConfigProperty(String name) { requireNonNull(name, "Configuration property name should ne null"); if (configuration().remove(name) != null && !isNew()) { removeConfigPropertyFromXML(name); } return this; }
private void setConfiguration0(Map<String, String> configuration) { this.configuration = new HashMap<>(configuration); if (isNew()) return; if (pluginElement.hasSingleChild("configuration")) { final Element confElement = pluginElement.getSingleChild("configuration"); // remove all configuration properties from element for (Element property : confElement.getChildren()) { property.remove(); } // append each new property to "configuration" element for (Map.Entry<String, String> property : configuration.entrySet()) { confElement.appendChild(createElement(property.getKey(), property.getValue())); } } else { final NewElement newConfiguration = createElement("configuration"); for (Map.Entry<String, String> entry : configuration.entrySet()) { newConfiguration.appendChild(createElement(entry.getKey(), entry.getValue())); } // insert new configuration to xml pluginElement.appendChild(newConfiguration); } }
/** * Sets plugin group identifier * * @param groupId new group identifier, if new group id is {@code null} and current plugin element * related with xml element then <i>groupId</i> element will be removed from xml as well as * from plugin model * @return this plugin instance */ public Plugin setGroupId(String groupId) { this.groupId = groupId; if (!isNew()) { if (groupId == null) { pluginElement.removeChild("groupId"); } else if (pluginElement.hasSingleChild("groupId")) { pluginElement.getSingleChild("groupId").setText(groupId); } else { pluginElement.insertChild(createElement("groupId", groupId), inTheBegin()); } } return this; }
/** Sets plugin version. */ public Plugin setVersion(String version) { this.version = version; if (!isNew()) { if (version == null) { pluginElement.removeChild("version"); } else if (pluginElement.hasSingleChild("version")) { pluginElement.getSingleChild("version").setText(version); } else { pluginElement.insertChild( createElement("version", version), after("artifactId").or(inTheBegin())); } } return this; }
/** * Sets plugin artifact identifier * * @param artifactId new artifact identifier, if new artifact id is {@code null} and current * plugin element related with xml element then <i>artifactId</i> element will be removed from * xml as well as from plugin model * @return this plugin instance */ public Plugin setArtifactId(String artifactId) { this.artifactId = artifactId; if (!isNew()) { if (artifactId == null) { pluginElement.removeChild("artifactId"); } else if (pluginElement.hasSingleChild("artifactId")) { pluginElement.getSingleChild("artifactId").setText(artifactId); } else { pluginElement.insertChild( createElement("artifactId", artifactId), after("groupId").or(inTheBegin())); } } return this; }