Class PgxCollection<E,​ID>

  • Type Parameters:
    E - the element type
    ID - the ID type of the element type
    All Implemented Interfaces:
    java.lang.AutoCloseable, java.lang.Iterable<E>, oracle.pgx.common.IdentifiableCollection
    Direct Known Subclasses:
    GraphEntityCollection, ScalarCollection

    public abstract class PgxCollection<E,​ID>
    extends PgxManagedObject
    implements java.lang.Iterable<E>, oracle.pgx.common.IdentifiableCollection
    Superclass for Pgx collections.
    • Method Detail

      • getId

        public oracle.pgx.common.PgxId getId()
        Returns an internal identifier for this collection. Only meant for internal usage.
        Specified by:
        getId in interface oracle.pgx.common.IdentifiableCollection
        Returns:
        the internal identifier of this collection
        Since:
        20.0
      • getName

        public java.lang.String getName()
        Specified by:
        getName in class PgxManagedObject
        Returns:
        the name identifying this managed object
      • getGraph

        public PgxGraph getGraph()
        Gets the graph.
        Returns:
        the graph this PgxCollection is bound to
      • destroyAsync

        public PgxFuture<java.lang.Void> destroyAsync()
        Description copied from class: Destroyable
        Requests destruction of this object. After this method returns, the behavior of any method of this class becomes undefined.
        Specified by:
        destroyAsync in class Destroyable
        Returns:
        a future which will be completed once the destruction request finishes.
      • getCollectionType

        public CollectionType getCollectionType()
        Gets the collection type.
        Returns:
        the collection type
      • getContentType

        public PropertyType getContentType()
        Gets this collection's content type.
        Returns:
        this collection's content type
        Since:
        2.7.0
      • stream

        public java.util.stream.Stream<E> stream()
        Creates a new sequential or parallel Stream from Spliterator.
        Returns:
        a new sequential or parallel Stream
      • addAllAsync

        public PgxFuture<java.lang.Void> addAllAsync​(E[] elements)
        Add elements to an existing collection.
        Parameters:
        elements - elements to add
      • addAllElementsAsync

        public abstract PgxFuture<java.lang.Void> addAllElementsAsync​(java.util.Collection<E> source)
        Adds elements to an existing collection.
        Parameters:
        source - elements to add
      • removeAllElementsAsync

        public abstract PgxFuture<java.lang.Void> removeAllElementsAsync​(java.util.Collection<E> source)
        Removes elements from an existing collection.
        Parameters:
        source - elements to remove
      • clearAsync

        public PgxFuture<java.lang.Void> clearAsync()
        Clear an existing collection
      • cloneAsync

        public PgxFuture<PgxCollection<E,​ID>> cloneAsync​(java.lang.String newName)
        Clone an existing collection.
        Parameters:
        newName - name of the new collection
        Returns:
        the cloned collection
      • toMutableAsync

        public PgxFuture<PgxCollection<E,​ID>> toMutableAsync​(java.lang.String newName)
        Create a mutable copy of an existing collection
        Parameters:
        newName - name of the new collection
        Returns:
        the mutable copy
      • isMutableAsync

        public PgxFuture<java.lang.Boolean> isMutableAsync()
        Checks whether an existing collection is mutable
        Returns:
        true if the collection is mutable, false if it is immutable
      • toString

        public java.lang.String toString()
        (non-Javadoc)
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • getIdType

        public abstract IdType getIdType()
        Gets the ID type of the element type.
        Returns:
        the ID type of the element type.
      • sizeAsync

        public PgxFuture<java.lang.Integer> sizeAsync()
        Gets the number of elements in this collection
        Returns:
        number of elements in this collection
      • iteratorAsync

        public PgxFuture<java.util.Iterator<E>> iteratorAsync()
        Gets an Iterator over the collection.
        Returns:
        an Iterator over the collection
      • add

        public void add​(E entity)
        Adds one element to this collection.
        Parameters:
        entity - the entity
      • remove

        public void remove​(E entity)
        Removes one element from this collection.
        Parameters:
        entity - the entity
      • containsAsync

        public abstract PgxFuture<java.lang.Boolean> containsAsync​(E element)
        Returns true if this collection contains the specified element.
        Parameters:
        element - element whose presence in this collection is to be tested
        Returns:
        true if this collection contains the specified element
      • iterator

        public java.util.Iterator<E> iterator()
        Blocking version of iteratorAsync(). Calls iteratorAsync() and waits for the returned PgxFuture to complete.
        Specified by:
        iterator in interface java.lang.Iterable<E>
      • addAll

        public abstract void addAll​(PgxEntity[] elements)
        Adds elements of a PgxEntity array to this collection.
        Parameters:
        elements - the PgxEntity array containing the elements to add
      • toMutable

        public PgxCollection<E,​ID> toMutable()
                                            throws java.util.concurrent.ExecutionException,
                                                   java.lang.InterruptedException
        Blocking version of toMutableAsync(). Calls toMutableAsync() and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • toMutable

        public PgxCollection<E,​ID> toMutable​(java.lang.String newName)
                                            throws java.util.concurrent.ExecutionException,
                                                   java.lang.InterruptedException
        Blocking version of toMutableAsync(String). Calls toMutableAsync(String) and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • isMutable

        public boolean isMutable()
                          throws java.util.concurrent.ExecutionException,
                                 java.lang.InterruptedException
        Blocking version of isMutableAsync(). Calls isMutableAsync() and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • clone

        public PgxCollection<E,​ID> clone​(java.lang.String newName)
                                        throws java.lang.InterruptedException,
                                               java.util.concurrent.ExecutionException
        Blocking version of clone(String). Calls clone(String) and waits for the returned PgxFuture to complete.
        Throws:
        java.util.concurrent.ExecutionException
        java.lang.InterruptedException
      • contains

        public boolean contains​(E element)
        Blocking version of #containsAsync(E). Calls #containsAsync(E) and waits for the returned PgxFuture to complete.