Skip to content

Commit

Permalink
use much clearer solution with Set instead of List
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Tymel committed Jun 21, 2016
1 parent f7e0bca commit 3810149
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.wildfly.extras.creaper.commands.foundation.offline.xml.GroovyXmlTransform;
import org.wildfly.extras.creaper.commands.foundation.offline.xml.Subtree;
import org.wildfly.extras.creaper.core.offline.OfflineCommand;
Expand Down Expand Up @@ -148,10 +150,9 @@ public Builder removeHandlers(String... handlers) {

public ChangeAuditLogger build() {
if (addHandlers != null && removeHandlers != null) {
List<String> auxList = new ArrayList<String>();
auxList.addAll(addHandlers);
auxList.removeAll(removeHandlers);
if (auxList.size() < addHandlers.size()) {
Set<String> intersection = new HashSet<String>(addHandlers);
intersection.retainAll(removeHandlers);
if (!intersection.isEmpty()) {
throw new IllegalArgumentException("handler can not be added and removed at the same time");
}
}
Expand Down

0 comments on commit 3810149

Please sign in to comment.