Skip to content

Commit

Permalink
include changes to aspect for default base aspect in artemis-gwt
Browse files Browse the repository at this point in the history
  • Loading branch information
schosin committed Dec 8, 2019
1 parent a17f462 commit 984edf2
Showing 1 changed file with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -212,14 +213,29 @@ public static Aspect.Builder one(Class<? extends Component>... types) {
public static Aspect.Builder one(Collection<Class<? extends Component>> 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<Class<? extends Component>> allTypes;
private final Bag<Class<? extends Component>> exclusionTypes;
private final Bag<Class<? extends Component>> oneTypes;
final Bag<Class<? extends Component>> allTypes;
final Bag<Class<? extends Component>> exclusionTypes;
final Bag<Class<? extends Component>> oneTypes;
boolean defaults = true;

private Builder() {
allTypes = new Bag<Class<? extends Component>>();
Expand Down Expand Up @@ -251,6 +267,7 @@ public Builder copy() {
b.allTypes.addAll(allTypes);
b.exclusionTypes.addAll(exclusionTypes);
b.oneTypes.addAll(oneTypes);
b.defaults = defaults;
return b;
}

Expand All @@ -263,7 +280,7 @@ public Builder copy() {
*
* @return an aspect that can be matched against entities
*/
public Builder all(Collection<Class<? extends Component>> types) {
public Builder all(Iterable<Class<? extends Component>> types) {
for (Class<? extends Component> t : types) {
allTypes.add(t);
}
Expand Down Expand Up @@ -296,7 +313,7 @@ public Builder one(Class<? extends Component>... types) {
*
* @return an aspect that can be matched against entities
*/
public Builder one(Collection<Class<? extends Component>> types) {
public Builder one(Iterable<Class<? extends Component>> types) {
for (Class<? extends Component> t : types)
oneTypes.add(t);

Expand Down Expand Up @@ -335,12 +352,28 @@ public Builder exclude(Class<? extends Component>... types) {
*
* @return an aspect that can be matched against entities
*/
public Builder exclude(Collection<Class<? extends Component>> types) {
public Builder exclude(Iterable<Class<? extends Component>> types) {
for (Class<? extends Component> 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.
Expand Down Expand Up @@ -394,6 +427,7 @@ public String toString() {
"all=" + append(allTypes) +
", one=" + append(oneTypes) +
", exclude=" + append(exclusionTypes) +
", defaults=" + defaults +
']';
}

Expand Down

0 comments on commit 984edf2

Please sign in to comment.