Class ConditionalExistenceCollections.ConditionalExistenceSet<E>

  • Type Parameters:
    E - type of element in set
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>
    Enclosing class:
    ConditionalExistenceCollections

    static final class ConditionalExistenceCollections.ConditionalExistenceSet<E>
    extends java.util.AbstractSet<E>
    Elements in this set only exist if a certain condition is true.
    Since:
    2019-10-17
    Author:
    Adrien Hopkins
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.function.Predicate<E> existenceCondition  
      private java.util.Set<E> set  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ConditionalExistenceSet​(java.util.Set<E> set, java.util.function.Predicate<E> existenceCondition)
      Creates the ConditionalNonexistenceSet.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E e)
      void clear()  
      boolean contains​(java.lang.Object o)  
      java.util.Iterator<E> iterator()  
      boolean remove​(java.lang.Object o)  
      int size()  
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        addAll, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
    • Field Detail

      • set

        private final java.util.Set<E> set
      • existenceCondition

        private final java.util.function.Predicate<E> existenceCondition
    • Constructor Detail

      • ConditionalExistenceSet

        private ConditionalExistenceSet​(java.util.Set<E> set,
                                        java.util.function.Predicate<E> existenceCondition)
        Creates the ConditionalNonexistenceSet.
        Parameters:
        set - set to use
        existenceCondition - condition where element exists
        Since:
        2019-10-17
    • Method Detail

      • add

        public boolean add​(E e)

        Note that this method returns false if e does not pass the existence condition.

        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.Set<E>
        Overrides:
        add in class java.util.AbstractCollection<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.Set<E>
        Overrides:
        clear in class java.util.AbstractCollection<E>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
        Specified by:
        iterator in class java.util.AbstractCollection<E>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.Set<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.Set<E>
        Specified by:
        size in class java.util.AbstractCollection<E>