Package net.sf.freecol.common.model
Class ScopeContainer
- java.lang.Object
-
- net.sf.freecol.common.model.ScopeContainer
-
public class ScopeContainer extends java.lang.Object
How scopes are handled.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<Scope>
noList
Cached empty scope list.private static java.util.stream.Stream<Scope>
noStream
Cached empty scope stream.private static java.util.Comparator<Scope>
scopeComparator
Cached standard scope comparator.private java.util.List<Scope>
scopes
The scopes.
-
Constructor Summary
Constructors Constructor Description ScopeContainer()
Trivial constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Scope scope)
Add a scope.void
addAll(java.util.Collection<Scope> c)
Add all ths scopes from a collection.void
addAll(ScopeContainer other)
Add all the scopes in another scope container.static ScopeContainer
addScope(ScopeContainer sc, Scope scope)
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.void
clear()
Clear the scopes.static void
clearScopes(ScopeContainer sc)
boolean
equals(java.lang.Object o)
static boolean
equalScopes(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)
int
hashCode()
boolean
isEmpty()
Is this container empty?static boolean
isScopeContainerEmpty(ScopeContainer sc)
void
remove(Scope scope)
Remove a scope.static void
removeScope(ScopeContainer sc, Scope scope)
static boolean
scopeContainerAppliesTo(ScopeContainer sc, FreeColObject fco)
static void
scopeContainerToXML(ScopeContainer sc, FreeColXMLWriter xw)
void
set(java.util.List<Scope> scopes)
Set the scopes for this object.static ScopeContainer
setScopes(ScopeContainer sc, java.util.Collection<Scope> c)
void
sort(java.util.Comparator<Scope> comp)
Sort the scopes.void
toXML(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
Scope
s.
-
get
public final java.util.stream.Stream<Scope> get()
Get the scopes applicable to this effect as a stream.- Returns:
- A stream of
Scope
s.
-
set
public final void set(java.util.List<Scope> scopes)
Set the scopes for this object.- Parameters:
scopes
- A list of newScope
s.
-
clear
public final void clear()
Clear the scopes.
-
add
public final void add(Scope scope)
Add a scope.- Parameters:
scope
- TheScope
to add.
-
addAll
public final void addAll(java.util.Collection<Scope> c)
Add all ths scopes from a collection.- Parameters:
c
- TheCollection
to 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
- TheScope
to remove.
-
sort
public final void sort(java.util.Comparator<Scope> comp)
Sort the scopes.- Parameters:
comp
- TheComparator
that 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
- TheFreeColObject
to 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
- TheFreeColXMLWriter
to 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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
-
-