Class MagellanOrdersImplementation

  • All Implemented Interfaces:
    java.lang.Iterable<Order>, java.util.Collection<Order>, java.util.List<Order>, Orders

    public class MagellanOrdersImplementation
    extends java.lang.Object
    implements Orders
    A class for handling orders in the Unit object.
    • Constructor Detail

      • MagellanOrdersImplementation

        public MagellanOrdersImplementation​(Unit u)
        Creates a new Orders object.
      • MagellanOrdersImplementation

        public MagellanOrdersImplementation​(Unit u,
                                            java.util.List<Order> list)
        Creates a new Orders object. The orders are backed by list, i.e. changes in the list also change this orders object.
        Parameters:
        list -
    • Method Detail

      • removeOrder

        public boolean removeOrder​(Order order,
                                   int length)
        Description copied from interface: Orders
        Removes orders that match the given order up to a given length.
        Specified by:
        removeOrder in interface Orders
        Parameters:
        order - pattern to remove
        length - denotes the number of tokens that need to be equal for a replacement. E.g. specify 2 if order is "BENENNE EINHEIT abc" and all "BENENNE EINHEIT" orders should be replaced but not all "BENENNE" orders.
        Returns:
        true if at least one order was removed
        See Also:
        Orders.removeOrder(magellan.library.Order, int)
      • equalsCompletedToken

        protected boolean equalsCompletedToken​(OrderToken token,
                                               StringID order)
      • getOrderTranslations

        protected java.util.List<java.lang.String> getOrderTranslations​(StringID orderId)
      • getView

        public Orders getView()
        Returns an unmodifiable copy of this object.
      • getUnit

        public Unit getUnit()
        Description copied from interface: Orders
        Returns the unit owning these orders. It is not guaranteed, that this orders object is actually attached to the unit.
        Specified by:
        getUnit in interface Orders
        Returns:
        The unit owning these orders.
        See Also:
        Orders.getUnit()
      • isToken

        public boolean isToken​(Order order,
                               int i,
                               StringID token)
        Description copied from interface: Orders
        Compares an order token to a order constant. This method translates the token to the unit's order locale and compares it to the specified order token.
        Specified by:
        isToken in interface Orders
        Parameters:
        order - An order
        i - A token position
        token - An order name. Usually one of the order ("O_...") constants from EresseaConstants.
        Returns:
        true if the order token at the position is a significant prefix of the translation of the given order token
        See Also:
        Orders.isToken(magellan.library.Order, int, StringID)
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<Order>
        Specified by:
        isEmpty in interface java.util.List<Order>
        Returns:
        true if there are no orders
        See Also:
        List.isEmpty()
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<Order>
        Specified by:
        contains in interface java.util.List<Order>
        See Also:
        List.contains(java.lang.Object)
      • iterator

        public java.util.Iterator<Order> iterator()
        Specified by:
        iterator in interface java.util.Collection<Order>
        Specified by:
        iterator in interface java.lang.Iterable<Order>
        Specified by:
        iterator in interface java.util.List<Order>
        See Also:
        List.iterator()
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<Order>
        Specified by:
        toArray in interface java.util.List<Order>
        See Also:
        List.toArray()
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<Order>
        Specified by:
        toArray in interface java.util.List<Order>
        See Also:
        java.util.List#toArray(T[])
      • add

        public boolean add​(Order e)
        Specified by:
        add in interface java.util.Collection<Order>
        Specified by:
        add in interface java.util.List<Order>
        See Also:
        List.add(java.lang.Object)
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<Order>
        Specified by:
        remove in interface java.util.List<Order>
        See Also:
        List.remove(java.lang.Object)
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<Order>
        Specified by:
        containsAll in interface java.util.List<Order>
        Parameters:
        c -
        See Also:
        List.containsAll(java.util.Collection)
      • addAll

        public boolean addAll​(java.util.Collection<? extends Order> c)
        Specified by:
        addAll in interface java.util.Collection<Order>
        Specified by:
        addAll in interface java.util.List<Order>
        Parameters:
        c -
        See Also:
        List.addAll(java.util.Collection)
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends Order> c)
        Specified by:
        addAll in interface java.util.List<Order>
        Parameters:
        index -
        c -
        See Also:
        List.addAll(int, java.util.Collection)
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<Order>
        Specified by:
        removeAll in interface java.util.List<Order>
        Parameters:
        c -
        See Also:
        List.removeAll(java.util.Collection)
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<Order>
        Specified by:
        retainAll in interface java.util.List<Order>
        Parameters:
        c -
        See Also:
        List.retainAll(java.util.Collection)
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<Order>
        Specified by:
        clear in interface java.util.List<Order>
        See Also:
        List.clear()
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<Order>
        Specified by:
        equals in interface java.util.List<Order>
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o -
        See Also:
        List.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<Order>
        Specified by:
        hashCode in interface java.util.List<Order>
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        List.hashCode()
      • get

        public Order get​(int index)
        Specified by:
        get in interface java.util.List<Order>
        Parameters:
        index -
        See Also:
        List.get(int)
      • set

        public Order set​(int index,
                         Order element)
        Specified by:
        set in interface java.util.List<Order>
        Parameters:
        index -
        element -
        See Also:
        List.set(int, java.lang.Object)
      • add

        public void add​(int index,
                        Order element)
        Specified by:
        add in interface java.util.List<Order>
        Parameters:
        index -
        element -
        See Also:
        List.add(int, java.lang.Object)
      • remove

        public Order remove​(int index)
        Specified by:
        remove in interface java.util.List<Order>
        Parameters:
        index -
        See Also:
        List.remove(int)
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<Order>
        Parameters:
        o -
        See Also:
        List.indexOf(java.lang.Object)
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<Order>
        Parameters:
        o -
        See Also:
        List.lastIndexOf(java.lang.Object)
      • listIterator

        public java.util.ListIterator<Order> listIterator()
        Specified by:
        listIterator in interface java.util.List<Order>
        See Also:
        List.listIterator()
      • listIterator

        public java.util.ListIterator<Order> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<Order>
        Parameters:
        index -
        See Also:
        List.listIterator(int)
      • subList

        public java.util.List<Order> subList​(int fromIndex,
                                             int toIndex)
        Specified by:
        subList in interface java.util.List<Order>
        Throws:
        java.lang.UnsupportedOperationException
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<Order>
        Specified by:
        size in interface java.util.List<Order>
        See Also:
        List.size()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object