Skip to content

Commit

Permalink
move deduplicate to a new method
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 13, 2019
1 parent 000e7b0 commit dc19d3d
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@ else if (showFailure) {
return results;
}

public ListTag deduplicate() {
ListTag list = new ListTag();
int size = size();
for (int i = 0; i < size; i++) {
String entry = get(i);
boolean duplicate = false;
for (int x = 0; x < i; x++) {
if (get(x).equalsIgnoreCase(entry)) {
duplicate = true;
break;
}
}
if (!duplicate) {
list.addObject(objectForms.get(i));
}
}
return list;
}

@Override
public String toString() {
Expand Down Expand Up @@ -1003,23 +1021,7 @@ public ObjectTag run(Attribute attribute, ListTag object) {
registerTag("deduplicate", new TagRunnable.ObjectForm<ListTag>() {
@Override
public ObjectTag run(Attribute attribute, ListTag object) {
ListTag obj = object;
ListTag list = new ListTag();
int size = obj.size();
for (int i = 0; i < size; i++) {
String entry = obj.get(i);
boolean duplicate = false;
for (int x = 0; x < i; x++) {
if (obj.get(x).equalsIgnoreCase(entry)) {
duplicate = true;
break;
}
}
if (!duplicate) {
list.addObject(obj.objectForms.get(i));
}
}
return list;
return object.deduplicate();
}
});

Expand Down Expand Up @@ -2001,7 +2003,6 @@ public ObjectTag run(Attribute attribute, ListTag object) {
return new ElementTag("List");
}
});

}

public static ObjectTagProcessor<ListTag> tagProcessor = new ObjectTagProcessor<>();
Expand Down

0 comments on commit dc19d3d

Please sign in to comment.