Class ScopeContainer


  • public class ScopeContainer
    extends java.lang.Object
    How scopes are handled.
    • 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.
    • Constructor Detail

      • ScopeContainer

        public ScopeContainer()
        Trivial constructor.
    • 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 new Scopes.
      • clear

        public final void clear()
        Clear the scopes.
      • add

        public final void add​(Scope scope)
        Add a scope.
        Parameters:
        scope - The Scope to add.
      • addAll

        public final void addAll​(java.util.Collection<Scope> c)
        Add all ths scopes from a collection.
        Parameters:
        c - The Collection to add from.
      • addAll

        public final void addAll​(ScopeContainer other)
        Add all the scopes in another scope container.
        Parameters:
        other - The other ScopeContainer.
      • remove

        public final void remove​(Scope scope)
        Remove a scope.
        Parameters:
        scope - The Scope to remove.
      • sort

        public final void sort​(java.util.Comparator<Scope> comp)
        Sort the scopes.
        Parameters:
        comp - The Comparator 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 - The FreeColObject 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 - The FreeColXMLWriter 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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isScopeContainerEmpty

        public static boolean isScopeContainerEmpty​(ScopeContainer sc)
      • scopeContainerToXML

        public static void scopeContainerToXML​(ScopeContainer sc,
                                               FreeColXMLWriter xw)
                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException