FCollection: can't inherit from Set anymore because the interfaces might colide

This commit is contained in:
Hanmac
2017-06-10 13:24:52 +00:00
parent a844577e1a
commit a39ac85b15
4 changed files with 9 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ import java.util.Set;
* @param <T> the type of the elements this collection contains.
* @see FCollectionView
*/
public class FCollection<T> implements List<T>, Set<T>, FCollectionView<T>, Cloneable, Serializable {
public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>, Cloneable, Serializable {
private static final long serialVersionUID = -1664555336364294106L;
private static final FCollection<?> EMPTY = new EmptyFCollection<Object>();
@@ -200,6 +200,10 @@ public class FCollection<T> implements List<T>, Set<T>, FCollectionView<T>, Clon
public boolean isEmpty() {
return set.isEmpty();
}
public Set<T> asSet() {
return set;
}
/**
* Check whether this collection contains a particular object.

View File

@@ -680,7 +680,7 @@ public class GameAction {
}
public final void checkStaticAbilities() {
checkStaticAbilities(true, new CardCollection());
checkStaticAbilities(true, Sets.<Card>newHashSet());
}
public final void checkStaticAbilities(final boolean runEvents, final Set<Card> affectedCards) {
if (isCheckingStaticAbilitiesOnHold()) {

View File

@@ -179,7 +179,7 @@ public class AttackConstraints {
// Now try all others (plus empty attack) and count their violations
final FCollection<Map<Card, GameEntity>> legalAttackers = collectLegalAttackers(reqs, myMax);
possible.putAll(Maps.asMap(legalAttackers, FN_COUNT_VIOLATIONS));
possible.putAll(Maps.asMap(legalAttackers.asSet(), FN_COUNT_VIOLATIONS));
possible.put(Collections.<Card, GameEntity>emptyMap(), countViolations(Collections.<Card, GameEntity>emptyMap()));
// take the case with the fewest violations
@@ -260,7 +260,7 @@ public class AttackConstraints {
}
for (final Predicate<Card> predicateRestriction : predicateRestrictions) {
if (Iterables.any(Sets.union(myAttackers.keySet(), reserved), predicateRestriction)) {
if (Iterables.any(Sets.union(myAttackers.keySet(), reserved.asSet()), predicateRestriction)) {
// predicate fulfilled already, ignore!
continue;
}

View File

@@ -214,7 +214,7 @@ public class Combat {
}
public final Map<Card, GameEntity> getAttackersAndDefenders() {
return Maps.asMap(getAttackers(), new Function<Card, GameEntity>() {
return Maps.asMap(getAttackers().asSet(), new Function<Card, GameEntity>() {
@Override
public GameEntity apply(final Card attacker) {
return getDefenderByAttacker(attacker);