Skip to content

Commit

Permalink
Make list.contains take a list
Browse files Browse the repository at this point in the history
basically a list.contains_all
  • Loading branch information
mcmonkey4eva committed Oct 20, 2014
1 parent dfa57d8 commit b0d91ab
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/net/aufdemrand/denizen/objects/dList.java
Expand Up @@ -1094,24 +1094,26 @@ else if (res > 0)
}

// <--[tag]
// @attribute <li@list.contains[<element>]>
// @attribute <li@list.contains[<element>|...]>
// @returns Element(Boolean)
// @description
// returns whether the list contains a given element.
// returns whether the list contains all of the given elements.
// -->
if (attribute.matches("contains")) {
if (attribute.hasContext(1)) {
boolean state = false;
if (attribute.matches("contains")
&& attribute.hasContext(1)) {
dList needed = dList.valueOf(attribute.getContext(1));
int gotten = 0;

for (String check: needed) {
for (String element : this) {
if (element.equalsIgnoreCase(attribute.getContext(1))) {
state = true;
if (element.equalsIgnoreCase(check)) {
gotten++;
break;
}
}

return new Element(state).getAttribute(attribute.fulfill(1));
}

return new Element(gotten == needed.size()).getAttribute(attribute.fulfill(1));
}

if (attribute.startsWith("prefix"))
Expand Down

0 comments on commit b0d91ab

Please sign in to comment.