Package io.jmix.core

Class EntitySet

java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingCollection<E>
com.google.common.collect.ForwardingSet<Object>
io.jmix.core.EntitySet
All Implemented Interfaces:
Serializable, Iterable<Object>, Collection<Object>, Set<Object>

public class EntitySet extends com.google.common.collect.ForwardingSet<Object> implements Serializable
Implementation of Set&lt;Entity&gt; with convenient methods for getting entities by a prototype instance or by a class and id.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    EntitySet(Collection<?> entities)
     
    EntitySet(Set<?> entities)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Set
     
    <T> T
    get(Class<T> entityClass, Object entityId)
    Returns the entity if it exists in the set.
    <T> T
    get(T prototype)
    Returns the entity if it exists in the set.
    <T> Collection<T>
    getAll(Class<T> entityClass)
    Returns a collection of entities of the specified class.
    static EntitySet
    of(Collection<?> entities)
    Creates the EntitySet by copying the given collection to the internal set.
    static EntitySet
    of(Set<?> entities)
    Creates the EntitySet wrapping an existing set.
    <T> Optional<T>
    optional(Class<T> entityClass, Object entityId)
    Returns the entity wrapped in Optional if it exists in the set.
    <T> Optional<T>
    optional(T prototype)
    Returns the entity wrapped in Optional if it exists in the set.

    Methods inherited from class com.google.common.collect.ForwardingSet

    equals, hashCode, standardEquals, standardHashCode, standardRemoveAll

    Methods inherited from class com.google.common.collect.ForwardingCollection

    add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray

    Methods inherited from class com.google.common.collect.ForwardingObject

    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

    add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray
  • Constructor Details

    • EntitySet

      public EntitySet()
    • EntitySet

      public EntitySet(Set<?> entities)
    • EntitySet

      public EntitySet(Collection<?> entities)
  • Method Details

    • of

      public static EntitySet of(Set<?> entities)
      Creates the EntitySet wrapping an existing set.
    • of

      public static EntitySet of(Collection<?> entities)
      Creates the EntitySet by copying the given collection to the internal set.
    • optional

      public <T> Optional<T> optional(Class<T> entityClass, Object entityId)
      Returns the entity wrapped in Optional if it exists in the set.
      Parameters:
      entityClass - class of entity
      entityId - entity id
    • optional

      public <T> Optional<T> optional(T prototype)
      Returns the entity wrapped in Optional if it exists in the set.
      Parameters:
      prototype - a prototype instance whose class and id are used to look up an entity in the set.
    • get

      public <T> T get(Class<T> entityClass, Object entityId)
      Returns the entity if it exists in the set.
      Parameters:
      entityClass - class of entity
      entityId - entity id
      Throws:
      IllegalArgumentException - if the entity not found
    • get

      public <T> T get(T prototype)
      Returns the entity if it exists in the set.
      Parameters:
      prototype - a prototype instance whose class and id are used to look up an entity in the set.
      Throws:
      IllegalArgumentException - if the entity not found
    • getAll

      public <T> Collection<T> getAll(Class<T> entityClass)
      Returns a collection of entities of the specified class.
      Parameters:
      entityClass - class of entities
    • delegate

      protected Set delegate()
      Specified by:
      delegate in class com.google.common.collect.ForwardingSet<Object>