Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
Using a local variable and putIfAbsent makes the code
more compact and legible
  • Loading branch information
tivervac committed Apr 26, 2024
1 parent d2ef4a6 commit 4801ce1
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1270,15 +1270,12 @@ private void updateIUContainerElements(Element containersElement, List<Element>
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node instanceof Element) {
if (repoURL == null
&& node.getNodeName().equalsIgnoreCase(TargetDefinitionPersistenceHelper.REPOSITORY)) {
String nodeName = node.getNodeName();
if (repoURL == null && nodeName.equalsIgnoreCase(TargetDefinitionPersistenceHelper.REPOSITORY)) {
repoURL = ((Element) node).getAttribute(TargetDefinitionPersistenceHelper.LOCATION);
if (!oldContainersByRepo.containsKey(repoURL)) {
oldContainersByRepo.put(repoURL, new ArrayList<>());
}
oldContainersByRepo.putIfAbsent(repoURL, new ArrayList<>());
oldContainersByRepo.get(repoURL).add(container);
} else if (node.getNodeName()
.equalsIgnoreCase(TargetDefinitionPersistenceHelper.INSTALLABLE_UNIT)) {
} else if (nodeName.equalsIgnoreCase(TargetDefinitionPersistenceHelper.INSTALLABLE_UNIT)) {
units.add((Element) node);
}
}
Expand All @@ -1297,11 +1294,10 @@ private void updateIUContainerElements(Element containersElement, List<Element>
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node instanceof Element) {
if (repoURL == null
&& node.getNodeName().equalsIgnoreCase(TargetDefinitionPersistenceHelper.REPOSITORY)) {
String nodeName = node.getNodeName();
if (repoURL == null && nodeName.equalsIgnoreCase(TargetDefinitionPersistenceHelper.REPOSITORY)) {
repoURL = ((Element) node).getAttribute(TargetDefinitionPersistenceHelper.LOCATION);
} else if (node.getNodeName()
.equalsIgnoreCase(TargetDefinitionPersistenceHelper.INSTALLABLE_UNIT)) {
} else if (nodeName.equalsIgnoreCase(TargetDefinitionPersistenceHelper.INSTALLABLE_UNIT)) {
units.add((Element) node);
}
}
Expand Down

0 comments on commit 4801ce1

Please sign in to comment.