diff --git a/artemis-backend-gwt/artemis-gwt/src/main/java/com/artemis/backends/gwt/emu/com/artemis/Aspect.java b/artemis-backend-gwt/artemis-gwt/src/main/java/com/artemis/backends/gwt/emu/com/artemis/Aspect.java index 5997a3855..d9d416dfe 100644 --- a/artemis-backend-gwt/artemis-gwt/src/main/java/com/artemis/backends/gwt/emu/com/artemis/Aspect.java +++ b/artemis-backend-gwt/artemis-gwt/src/main/java/com/artemis/backends/gwt/emu/com/artemis/Aspect.java @@ -1,6 +1,7 @@ package com.artemis; import com.artemis.utils.BitVector; +import java.lang.Iterable; import java.util.Collection; import com.artemis.utils.Bag; @@ -212,14 +213,29 @@ public static Aspect.Builder one(Class... types) { public static Aspect.Builder one(Collection> types) { return new Builder().one(types); } + + /** + * Changes whether the default aspect will be applied to this aspect + * when used for a subscription. + * + * @param defaults + * whether to apply default aspect + * + * @return an aspect that will have the default aspect applied to it + * depending on the value. + */ + public static Builder defaults(boolean defaults) { + return new Builder().defaults(defaults); + } /** * Constructs instances of {@link Aspect}. */ public static class Builder { - private final Bag> allTypes; - private final Bag> exclusionTypes; - private final Bag> oneTypes; + final Bag> allTypes; + final Bag> exclusionTypes; + final Bag> oneTypes; + boolean defaults = true; private Builder() { allTypes = new Bag>(); @@ -251,6 +267,7 @@ public Builder copy() { b.allTypes.addAll(allTypes); b.exclusionTypes.addAll(exclusionTypes); b.oneTypes.addAll(oneTypes); + b.defaults = defaults; return b; } @@ -263,7 +280,7 @@ public Builder copy() { * * @return an aspect that can be matched against entities */ - public Builder all(Collection> types) { + public Builder all(Iterable> types) { for (Class t : types) { allTypes.add(t); } @@ -296,7 +313,7 @@ public Builder one(Class... types) { * * @return an aspect that can be matched against entities */ - public Builder one(Collection> types) { + public Builder one(Iterable> types) { for (Class t : types) oneTypes.add(t); @@ -335,12 +352,28 @@ public Builder exclude(Class... types) { * * @return an aspect that can be matched against entities */ - public Builder exclude(Collection> types) { + public Builder exclude(Iterable> types) { for (Class t : types) exclusionTypes.add(t); return this; } + + /** + * Changes whether the default aspect will be applied to this aspect + * when used for a subscription. + * + * @param defaults + * whether to apply default aspect + * + * @return an aspect that will have the default aspect applied to it + * depending on the value. + */ + public Builder defaults(boolean defaults) { + this.defaults = defaults; + + return this; + } /** * Bake an aspect. @@ -394,6 +427,7 @@ public String toString() { "all=" + append(allTypes) + ", one=" + append(oneTypes) + ", exclude=" + append(exclusionTypes) + + ", defaults=" + defaults + ']'; }