Class OneOrMore<T>

  • Type Parameters:
    T - the iterable type.
    All Implemented Interfaces:
    Iterable<T>

    public class OneOrMore<T>
    extends Object
    implements Iterable<T>
    A OneOrMore in an Iterable that allows items to be added. It wraps an ArrayList or HashSet depending on whether deduplication is enabled. This class is designed to be used in the case when the iterable quite often just contains a single item. In the case only a single item is required, the class doesn't instantiate the Collection it just holds onto the single item. If additional items are added then a new backing collection is created to hold the multiple values.
    • Constructor Detail

      • OneOrMore

        public OneOrMore()
      • OneOrMore

        public OneOrMore​(boolean deduplicate)
      • OneOrMore

        public OneOrMore​(boolean deduplicate,
                         T item)
    • Method Detail

      • add

        public boolean add​(T item)
      • addAll

        public boolean addAll​(Collection<? extends T> items)
      • removeAnyItem

        public void removeAnyItem()
      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • contains

        public boolean contains​(Object o)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object