/** * Sets list of profiles. * * <p><b>Note: all existing profiles will be removed from model and xml as well</b> * * @param profiles new profiles */ public Model setProfiles(Collection<? extends Profile> profiles) { // remove existing profiles for (Profile profile : profiles()) { profile.remove(); } // add profiles if necessary if (profiles != null && !profiles.isEmpty()) { for (Profile profile : profiles) { addProfile(profile); } } else { root.removeChild("profiles"); this.profiles = null; } return this; }
/** * 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; }