11package com .artemis ;
22
33import com .artemis .utils .BitVector ;
4+ import java .lang .Iterable ;
45import java .util .Collection ;
56
67import com .artemis .utils .Bag ;
@@ -212,14 +213,29 @@ public static Aspect.Builder one(Class<? extends Component>... types) {
212213 public static Aspect .Builder one (Collection <Class <? extends Component >> types ) {
213214 return new Builder ().one (types );
214215 }
216+
217+ /**
218+ * Changes whether the default aspect will be applied to this aspect
219+ * when used for a subscription.
220+ *
221+ * @param defaults
222+ * whether to apply default aspect
223+ *
224+ * @return an aspect that will have the default aspect applied to it
225+ * depending on the value.
226+ */
227+ public static Builder defaults (boolean defaults ) {
228+ return new Builder ().defaults (defaults );
229+ }
215230
216231 /**
217232 * Constructs instances of {@link Aspect}.
218233 */
219234 public static class Builder {
220- private final Bag <Class <? extends Component >> allTypes ;
221- private final Bag <Class <? extends Component >> exclusionTypes ;
222- private final Bag <Class <? extends Component >> oneTypes ;
235+ final Bag <Class <? extends Component >> allTypes ;
236+ final Bag <Class <? extends Component >> exclusionTypes ;
237+ final Bag <Class <? extends Component >> oneTypes ;
238+ boolean defaults = true ;
223239
224240 private Builder () {
225241 allTypes = new Bag <Class <? extends Component >>();
@@ -251,6 +267,7 @@ public Builder copy() {
251267 b .allTypes .addAll (allTypes );
252268 b .exclusionTypes .addAll (exclusionTypes );
253269 b .oneTypes .addAll (oneTypes );
270+ b .defaults = defaults ;
254271 return b ;
255272 }
256273
@@ -263,7 +280,7 @@ public Builder copy() {
263280 *
264281 * @return an aspect that can be matched against entities
265282 */
266- public Builder all (Collection <Class <? extends Component >> types ) {
283+ public Builder all (Iterable <Class <? extends Component >> types ) {
267284 for (Class <? extends Component > t : types ) {
268285 allTypes .add (t );
269286 }
@@ -296,7 +313,7 @@ public Builder one(Class<? extends Component>... types) {
296313 *
297314 * @return an aspect that can be matched against entities
298315 */
299- public Builder one (Collection <Class <? extends Component >> types ) {
316+ public Builder one (Iterable <Class <? extends Component >> types ) {
300317 for (Class <? extends Component > t : types )
301318 oneTypes .add (t );
302319
@@ -335,12 +352,28 @@ public Builder exclude(Class<? extends Component>... types) {
335352 *
336353 * @return an aspect that can be matched against entities
337354 */
338- public Builder exclude (Collection <Class <? extends Component >> types ) {
355+ public Builder exclude (Iterable <Class <? extends Component >> types ) {
339356 for (Class <? extends Component > t : types )
340357 exclusionTypes .add (t );
341358
342359 return this ;
343360 }
361+
362+ /**
363+ * Changes whether the default aspect will be applied to this aspect
364+ * when used for a subscription.
365+ *
366+ * @param defaults
367+ * whether to apply default aspect
368+ *
369+ * @return an aspect that will have the default aspect applied to it
370+ * depending on the value.
371+ */
372+ public Builder defaults (boolean defaults ) {
373+ this .defaults = defaults ;
374+
375+ return this ;
376+ }
344377
345378 /**
346379 * Bake an aspect.
@@ -394,6 +427,7 @@ public String toString() {
394427 "all=" + append (allTypes ) +
395428 ", one=" + append (oneTypes ) +
396429 ", exclude=" + append (exclusionTypes ) +
430+ ", defaults=" + defaults +
397431 ']' ;
398432 }
399433
0 commit comments