Class ImmutableQuadrupletonSet<T>

All Implemented Interfaces:
Serializable, Iterable<T>, Collection<T>, Set<T>, ImmutableCollection<T>, InternalIterable<T>, RichIterable<T>, ImmutableSet<T>, ImmutableSetIterable<T>, SetIterable<T>, UnsortedSetIterable<T>

final class ImmutableQuadrupletonSet<T> extends AbstractImmutableSet<T> implements Serializable
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • element1

      private final T element1
    • element2

      private final T element2
    • element3

      private final T element3
    • element4

      private final T element4
  • Constructor Details

    • ImmutableQuadrupletonSet

      ImmutableQuadrupletonSet(T obj1, T obj2, T obj3, T obj4)
  • Method Details

    • size

      public int size()
      Description copied from interface: RichIterable
      Returns the number of items in this iterable.
      Specified by:
      size in interface Collection<T>
      Specified by:
      size in interface RichIterable<T>
      Specified by:
      size in interface Set<T>
    • equals

      public boolean equals(Object other)
      Description copied from interface: SetIterable
      Follows the same general contract as Set.equals(Object).
      Specified by:
      equals in interface Collection<T>
      Specified by:
      equals in interface Set<T>
      Specified by:
      equals in interface SetIterable<T>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Description copied from interface: SetIterable
      Follows the same general contract as Set.hashCode().
      Specified by:
      hashCode in interface Collection<T>
      Specified by:
      hashCode in interface Set<T>
      Specified by:
      hashCode in interface SetIterable<T>
      Overrides:
      hashCode in class Object
    • newWith

      public ImmutableSet<T> newWith(T element)
      Description copied from interface: ImmutableCollection
      This method is similar to the with method in MutableCollection with the difference that a new copy of this collection with the element appended will be returned.
      Specified by:
      newWith in interface ImmutableCollection<T>
      Specified by:
      newWith in interface ImmutableSet<T>
      Overrides:
      newWith in class AbstractImmutableSet<T>
    • newWithout

      public ImmutableSet<T> newWithout(T element)
      Description copied from interface: ImmutableCollection
      This method is similar to the without method in MutableCollection with the difference that a new copy of this collection with the element removed will be returned.
      Specified by:
      newWithout in interface ImmutableCollection<T>
      Specified by:
      newWithout in interface ImmutableSet<T>
      Overrides:
      newWithout in class AbstractImmutableSet<T>
    • contains

      public boolean contains(Object obj)
      Description copied from interface: RichIterable
      Returns true if the iterable has an element which responds true to element.equals(object).
      Specified by:
      contains in interface Collection<T>
      Specified by:
      contains in interface RichIterable<T>
      Specified by:
      contains in interface Set<T>
      Overrides:
      contains in class AbstractRichIterable<T>
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Collection<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface Set<T>
    • getFirst

      public T getFirst()
      Description copied from interface: RichIterable
      Returns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.

      The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.

      Specified by:
      getFirst in interface RichIterable<T>
    • getLast

      public T getLast()
      Description copied from interface: RichIterable
      Returns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.

      The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.

      Specified by:
      getLast in interface RichIterable<T>
    • getOnly

      public T getOnly()
      Description copied from interface: RichIterable
      Returns the element if the iterable has exactly one element. Otherwise, throw IllegalStateException.
      Specified by:
      getOnly in interface RichIterable<T>
      Returns:
      an element of an iterable.
    • each

      public void each(Procedure<? super T> procedure)
      Description copied from interface: RichIterable
      The procedure is executed for each element in the iterable.

      Example using a Java 8 lambda expression:

       people.each(person -> LOGGER.info(person.getName()));
       

      Example using an anonymous inner class:

       people.each(new Procedure<Person>()
       {
           public void value(Person person)
           {
               LOGGER.info(person.getName());
           }
       });
       
      This method is a variant of InternalIterable.forEach(Procedure) that has a signature conflict with Iterable.forEach(java.util.function.Consumer).
      Specified by:
      each in interface RichIterable<T>
      See Also:
    • forEachWithIndex

      public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
      Description copied from interface: InternalIterable
      Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

      Example using a Java 8 lambda:

       people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
       

      Example using an anonymous inner class:

       people.forEachWithIndex(new ObjectIntProcedure<Person>()
       {
           public void value(Person person, int index)
           {
               LOGGER.info("Index: " + index + " person: " + person.getName());
           }
       });
       
      Specified by:
      forEachWithIndex in interface InternalIterable<T>
      Overrides:
      forEachWithIndex in class AbstractRichIterable<T>
    • forEachWith

      public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
      Description copied from interface: InternalIterable
      The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

      Example using a Java 8 lambda:

       people.forEachWith((Person person, Person other) ->
           {
               if (person.isRelatedTo(other))
               {
                    LOGGER.info(person.getName());
               }
           }, fred);
       

      Example using an anonymous inner class:

       people.forEachWith(new Procedure2<Person, Person>()
       {
           public void value(Person person, Person other)
           {
               if (person.isRelatedTo(other))
               {
                    LOGGER.info(person.getName());
               }
           }
       }, fred);
       
      Specified by:
      forEachWith in interface InternalIterable<T>
      Overrides:
      forEachWith in class AbstractRichIterable<T>
    • writeReplace

      private Object writeReplace()