Package net.sf.freecol.common.model
Class ScopeContainer
- java.lang.Object
-
- net.sf.freecol.common.model.ScopeContainer
-
public class ScopeContainer extends java.lang.ObjectHow scopes are handled.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<Scope>noListCached empty scope list.private static java.util.stream.Stream<Scope>noStreamCached empty scope stream.private static java.util.Comparator<Scope>scopeComparatorCached standard scope comparator.private java.util.List<Scope>scopesThe scopes.
-
Constructor Summary
Constructors Constructor Description ScopeContainer()Trivial constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Scope scope)Add a scope.voidaddAll(java.util.Collection<Scope> c)Add all ths scopes from a collection.voidaddAll(ScopeContainer other)Add all the scopes in another scope container.static ScopeContaineraddScope(ScopeContainer sc, Scope scope)booleanappliesTo(FreeColObject object)Does this scope container apply to the given object? Trivially true if there are no actual scopes present, otherwise at least one of the scopes must apply directly.voidclear()Clear the scopes.static voidclearScopes(ScopeContainer sc)booleanequals(java.lang.Object o)static booleanequalScopes(ScopeContainer sc1, ScopeContainer sc2)java.util.stream.Stream<Scope>get()Get the scopes applicable to this effect as a stream.java.util.List<Scope>getList()Get the scopes applicable to this effect.static java.util.List<Scope>getScopeList(ScopeContainer sc)static java.util.stream.Stream<Scope>getScopes(ScopeContainer sc)inthashCode()booleanisEmpty()Is this container empty?static booleanisScopeContainerEmpty(ScopeContainer sc)voidremove(Scope scope)Remove a scope.static voidremoveScope(ScopeContainer sc, Scope scope)static booleanscopeContainerAppliesTo(ScopeContainer sc, FreeColObject fco)static voidscopeContainerToXML(ScopeContainer sc, FreeColXMLWriter xw)voidset(java.util.List<Scope> scopes)Set the scopes for this object.static ScopeContainersetScopes(ScopeContainer sc, java.util.Collection<Scope> c)voidsort(java.util.Comparator<Scope> comp)Sort the scopes.voidtoXML(FreeColXMLWriter xw)Write the scopes to a stream.
-
-
-
Field Detail
-
noStream
private static final java.util.stream.Stream<Scope> noStream
Cached empty scope stream.
-
noList
private static final java.util.List<Scope> noList
Cached empty scope list.
-
scopeComparator
private static final java.util.Comparator<Scope> scopeComparator
Cached standard scope comparator.
-
scopes
private java.util.List<Scope> scopes
The scopes.
-
-
Method Detail
-
isEmpty
public final boolean isEmpty()
Is this container empty?- Returns:
- True if no scopes are present.
-
getList
public final java.util.List<Scope> getList()
Get the scopes applicable to this effect.- Returns:
- A list of
Scopes.
-
get
public final java.util.stream.Stream<Scope> get()
Get the scopes applicable to this effect as a stream.- Returns:
- A stream of
Scopes.
-
set
public final void set(java.util.List<Scope> scopes)
Set the scopes for this object.- Parameters:
scopes- A list of newScopes.
-
clear
public final void clear()
Clear the scopes.
-
add
public final void add(Scope scope)
Add a scope.- Parameters:
scope- TheScopeto add.
-
addAll
public final void addAll(java.util.Collection<Scope> c)
Add all ths scopes from a collection.- Parameters:
c- TheCollectionto add from.
-
addAll
public final void addAll(ScopeContainer other)
Add all the scopes in another scope container.- Parameters:
other- The otherScopeContainer.
-
remove
public final void remove(Scope scope)
Remove a scope.- Parameters:
scope- TheScopeto remove.
-
sort
public final void sort(java.util.Comparator<Scope> comp)
Sort the scopes.- Parameters:
comp- TheComparatorthat defines the ordering.
-
appliesTo
public boolean appliesTo(FreeColObject object)
Does this scope container apply to the given object? Trivially true if there are no actual scopes present, otherwise at least one of the scopes must apply directly.- Parameters:
object- TheFreeColObjectto check.- Returns:
- True if this effect applies.
-
toXML
public void toXML(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the scopes to a stream.- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isScopeContainerEmpty
public static boolean isScopeContainerEmpty(ScopeContainer sc)
-
getScopeList
public static java.util.List<Scope> getScopeList(ScopeContainer sc)
-
getScopes
public static java.util.stream.Stream<Scope> getScopes(ScopeContainer sc)
-
addScope
public static ScopeContainer addScope(ScopeContainer sc, Scope scope)
-
removeScope
public static void removeScope(ScopeContainer sc, Scope scope)
-
setScopes
public static ScopeContainer setScopes(ScopeContainer sc, java.util.Collection<Scope> c)
-
clearScopes
public static void clearScopes(ScopeContainer sc)
-
equalScopes
public static boolean equalScopes(ScopeContainer sc1, ScopeContainer sc2)
-
scopeContainerAppliesTo
public static boolean scopeContainerAppliesTo(ScopeContainer sc, FreeColObject fco)
-
scopeContainerToXML
public static void scopeContainerToXML(ScopeContainer sc, FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
-