/** * 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; }