@Override public Exclusion map(Element element) { return new Exclusion(element); } }
void remove() { if (!isNew()) { exclusionElement.remove(); exclusionElement = null; } }
private void setExclusions0(Collection<? extends Exclusion> exclusions) { for (Exclusion exclusion : exclusions()) { exclusion.remove(); } // use addExclusion to add and associate each new exclusion with element this.exclusions = new ArrayList<>(exclusions.size()); for (Exclusion exclusion : exclusions) { addExclusion(exclusion); } }
/** * Adds new exclusion to the list of dependency exclusions. * * <p>If dependency doesn't have exclusions then it will be added to xml. * * @param exclusion new exclusion which will be added * @return this dependency instance * @throws NullPointerException when {@code exclusion} is {@code null} */ public Dependency addExclusion(Exclusion exclusion) { requireNonNull(exclusion, "Required not null exclusion"); exclusions().add(exclusion); // add exclusion to xml tree if (!isNew()) { if (dependencyElement.hasSingleChild("exclusions")) { dependencyElement.getSingleChild("exclusions").appendChild(exclusion.asXMLElement()); } else { dependencyElement.appendChild(createElement("exclusions", exclusion.asXMLElement())); } exclusion.exclusionElement = dependencyElement.getSingleChild("exclusions").getLastChild(); } return this; }
NewElement asXMLElement() { final NewElement newElement = createElement("dependency"); newElement.appendChild(createElement("groupId", groupId)); newElement.appendChild(createElement("artifactId", artifactId)); newElement.appendChild(createElement("version", version)); if (scope != null && !scope.equals("compile")) { newElement.appendChild(createElement("scope", scope)); } if (type != null && !type.equals("jar")) { newElement.appendChild(createElement("type", type)); } if (classifier != null) { newElement.appendChild(createElement("classifier", classifier)); } if (optional != null) { newElement.appendChild(createElement("optional", optional)); } if (exclusions != null) { final NewElement exclusionsEl = createElement("exclusions"); for (Exclusion exclusion : exclusions) { exclusionsEl.appendChild(exclusion.asXMLElement()); } exclusionsEl.appendChild(exclusionsEl); } return newElement; }
/** Set the artifact ID of the project to exclude. */ public Exclusion setArtifactId(String artifactId) { this.artifactId = artifactId; if (!isNew()) { if (artifactId == null) { exclusionElement.removeChild("artifactId"); } else if (exclusionElement.hasSingleChild("artifactId")) { exclusionElement.getSingleChild("artifactId").setText(artifactId); } else { exclusionElement.appendChild(createElement("artifactId", artifactId)); } } return this; }
/** * Removes exclusion from the dependency exclusions. * * <p>If last exclusion has been removed removes exclusions element as well. * * @param exclusion exclusion which should be removed * @return this dependency instance * @throws NullPointerException when {@code exclusion} is {@code null} */ public Dependency removeExclusion(Exclusion exclusion) { requireNonNull(exclusion, "Required not null exclusion"); exclusions().remove(exclusion); // remove dependency from xml if (!isNew() && exclusions.isEmpty()) { dependencyElement.removeChild("exclusions"); exclusion.exclusionElement = null; } else { exclusion.remove(); } return this; }
/** Set the group ID of the project to exclude. */ public Exclusion setGroupId(String groupId) { this.groupId = groupId; if (!isNew()) { if (groupId == null) { exclusionElement.removeChild("groupId"); } else if (exclusionElement.hasSingleChild("groupId")) { exclusionElement.getSingleChild("groupId").setText(groupId); } else { exclusionElement.insertChild(createElement("groupId", groupId), inTheBegin()); } } return this; }