mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
IZone - adjusted parameter type or remove method
thrown away get/setUpdate methods battlefield.getCards(false) will return R/O list of cards - might lead to exceptions if callers attempt to modify the method's result.
This commit is contained in:
@@ -30,24 +30,6 @@ import forge.Card;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
interface IZone {
|
interface IZone {
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* setUpdate.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param b
|
|
||||||
* a boolean.
|
|
||||||
*/
|
|
||||||
void setUpdate(boolean b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getUpdate.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
boolean getUpdate();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -101,7 +83,7 @@ interface IZone {
|
|||||||
* @param o
|
* @param o
|
||||||
* a {@link java.lang.Object} object.
|
* a {@link java.lang.Object} object.
|
||||||
*/
|
*/
|
||||||
void remove(Object o);
|
void remove(Card o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.zone;
|
package forge.game.zone;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
@@ -181,7 +180,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final void remove(final Object o) {
|
public final void remove(final Card o) {
|
||||||
|
|
||||||
super.remove(o);
|
super.remove(o);
|
||||||
|
|
||||||
@@ -276,7 +275,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
|
|||||||
// getCards(false) to get Phased Out cards
|
// getCards(false) to get Phased Out cards
|
||||||
|
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
return new ArrayList<Card>(cardList);
|
return super.getCards(false);
|
||||||
}
|
}
|
||||||
return Lists.newArrayList(Iterables.filter(cardList, isNotPhased));
|
return Lists.newArrayList(Iterables.filter(cardList, isNotPhased));
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
|||||||
public Zone(final ZoneType zone) {
|
public Zone(final ZoneType zone) {
|
||||||
this.zoneName = zone;
|
this.zoneName = zone;
|
||||||
this.roCardList = Collections.unmodifiableList(cardList);
|
this.roCardList = Collections.unmodifiableList(cardList);
|
||||||
|
|
||||||
|
//System.out.println(zoneName + " (ct) " + Integer.toHexString(System.identityHashCode(roCardList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ BEGIN - these methods fire updateObservers() *************
|
// ************ BEGIN - these methods fire updateObservers() *************
|
||||||
@@ -191,7 +193,7 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
|||||||
* an Object
|
* an Object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void remove(final Object c) {
|
public void remove(final Card c) {
|
||||||
this.cardList.remove(c);
|
this.cardList.remove(c);
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
@@ -287,6 +289,7 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final List<Card> getCards() {
|
public final List<Card> getCards() {
|
||||||
|
//System.out.println(zoneName + ": " + Integer.toHexString(System.identityHashCode(roCardList)));
|
||||||
return this.getCards(true);
|
return this.getCards(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,29 +325,6 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the update.
|
|
||||||
*
|
|
||||||
* @param b
|
|
||||||
* a boolean.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public final void setUpdate(final boolean b) {
|
|
||||||
this.update = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Getter for the field <code>update</code>.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public final boolean getUpdate() {
|
|
||||||
return this.update;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* toString.
|
* toString.
|
||||||
|
|||||||
Reference in New Issue
Block a user