@Override public Profile map(Element element) { return new Profile(element); } }
/** * Sets collection of repositories. * * <p><b>Note: all existing repositories will be removed from profile and xml as well</b> * * @param repositories new plugin repositories */ public Profile setRepositories(Collection<? extends Repository> repositories) { for (Repository repository : repositories()) { repository.remove(); } if (repositories != null && !repositories.isEmpty()) { for (Repository repository : repositories) { addRepository(repository); } } else { element.removeChild("repositories"); this.repositories = null; } return this; }
private void removeModules() { if (!isNew()) { element.removeChild("modules"); } modules = null; }
/** Returns profile element as XML element. */ public NewElement asXMLElement() { final NewElement profile = createElement("profile"); if (!isNullOrEmpty(id)) { profile.appendChild(createElement("id", id)); } if (modules != null && !modules.isEmpty()) { profile.appendChild(newModulesXMLElement(modules)); } if (activation != null) { profile.appendChild(activation.asXMLElement()); } if (build != null) { profile.appendChild(build.asXMLElement()); } if (repositories != null && !repositories.isEmpty()) { profile.appendChild(newRepositoryElement(repositories)); } if (dependencies != null && !dependencies.get().isEmpty()) { profile.appendChild(newDependencyElement(dependencies.get())); } if (properties != null && !properties.isEmpty()) { profile.appendChild(newPropertiesElement(properties)); } if (dependencyManagement != null && !dependencyManagement.getDependencies().isEmpty()) { profile.appendChild(newDependencyManagementElement(dependencies.get())); } return profile; }
private void setModules0(Collection<String> modules) { this.modules = new ArrayList<>(modules); if (isNew()) return; // if modules element exists we should replace it children // with new set of modules, otherwise create element for it if (element.hasSingleChild("modules")) { final Element modulesElement = element.getSingleChild("modules"); if (modulesElement == null) { return; } // remove all modules from element for (Element module : modulesElement.getChildren()) { module.remove(); } // append each new module to "modules" element for (String module : modules) { element.appendChild(createElement("module", module)); } } else { element.insertChild(newModulesXMLElement(this.modules), before("build").or(inTheEnd())); } }
/** * Adds a profile to the mocel * * @param profile profile */ public Model addProfile(Profile profile) { requireNonNull(profile, "Required not null profile"); profiles().add(profile); // add profile to xml if (root.hasSingleChild("profiles")) { root.getSingleChild("profiles").appendChild(profile.asXMLElement()); profile.element = root.getLastChild(); } else { root.insertChild( createElement("profiles", profile.asXMLElement()), beforeAnyOf("name", "build", "modules").or(inTheEnd())); profile.element = root.getSingleChild("profiles").getFirstChild(); } return this; }
this.properties = fetchProperties(properties);
/** * Sets profile identifier. * * @param id new profile identifier, if it is {@code null} then <i>id</i> element will be removed * from xml if exists */ public Profile setId(String id) { this.id = id; if (!isNew()) { if (isNullOrEmpty(id)) { element.removeChild("id"); } else { final Element idElement = element.getSingleChild("id"); if (element.hasSingleChild("id") && idElement != null) { idElement.setText(id); } else { element.insertChild(createElement("id", id), inTheBegin()); } } } return this; }
/** * Sets build configuration, see {@link Activation} * * @param build new build * @return this profile instance */ public Profile setBuild(Build build) { this.build = build; if (!isNew()) { if (build == null) { element.removeChild("build"); } else if (element.hasSingleChild("build")) { element.removeChild("build"); element.appendChild(build.asXMLElement()); } else { element.appendChild(build.asXMLElement()); } } return this; }
/** * Sets activation configuration, see {@link Activation} * * @param activation new activation * @return this profile instance */ public Profile setActivation(Activation activation) { this.activation = activation; if (!isNew()) { if (activation == null) { element.removeChild("activation"); } else if (element.hasSingleChild("activation")) { element.removeChild("activation"); element.appendChild(activation.asXMLElement()); } else { element.appendChild(activation.asXMLElement()); } } return this; }