Class ProxyCollection<E>

  • Type Parameters:
    E - The element type
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, Lazy, LazyCollection<E>

    public class ProxyCollection<E>
    extends java.util.AbstractSet<E>
    implements LazyCollection<E>
    Class which holds a reference to a collection in the database
    Author:
    Matthew Wakeling
    • Constructor Summary

      Constructors 
      Constructor Description
      ProxyCollection​(ObjectStore os, InterMineObject o, java.lang.String fieldName, java.lang.Class<? extends E> clazz)
      Construct a ProxyCollection object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<E> asList()
      Return this Collection as a List.
      ResultsInfo getInfo()
      Returns Returns the current best estimate of the characteristics of the LazyCollection
      java.util.Collection<E> getMaterialisedCollection()
      Gets the collection if it is a real materialised collection.
      ObjectStore getObjectStore()
      Returns the ObjectStore that this proxy will use
      Query getQuery()
      Returns the Query used by this LazyCollection
      java.util.Iterator<E> iterator()
      void setBatchSize​(int size)
      Sets the number of rows requested from the ObjectStore whenever an execute call is made
      void setMaterialisedCollection​(java.util.Collection<E> coll)
      Sets the collection with a new materialised collection.
      void setNoExplain()
      Sets this LazyCollection to bypass the explain check in ObjectStore.execute().
      void setNoOptimise()
      Sets this LazyCollection to bypass the optimiser
      int size()
      Gets the number of elements in this collection
      java.lang.String toString()
      We override this here in order to prevent possible infinite recursion.
      • Methods inherited from class java.util.AbstractSet

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

        add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray
      • 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, remove, retainAll, spliterator, toArray, toArray
    • Constructor Detail

      • ProxyCollection

        public ProxyCollection​(ObjectStore os,
                               InterMineObject o,
                               java.lang.String fieldName,
                               java.lang.Class<? extends E> clazz)
        Construct a ProxyCollection object.
        Parameters:
        os - the ObjectStore from which to retrieve the collection
        o - the object containing the collection
        fieldName - the name of the collection
        clazz - the Class of the objects in the collection
    • Method Detail

      • getObjectStore

        public ObjectStore getObjectStore()
        Returns the ObjectStore that this proxy will use
        Specified by:
        getObjectStore in interface Lazy
        Returns:
        an ObjectStore
      • size

        public int size()
        Gets the number of elements in this collection
        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>
        Returns:
        the number of elements
      • 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>
      • getQuery

        public Query getQuery()
        Returns the Query used by this LazyCollection
        Specified by:
        getQuery in interface LazyCollection<E>
        Returns:
        a Query
      • setNoOptimise

        public void setNoOptimise()
        Sets this LazyCollection to bypass the optimiser
        Specified by:
        setNoOptimise in interface LazyCollection<E>
      • setNoExplain

        public void setNoExplain()
        Sets this LazyCollection to bypass the explain check in ObjectStore.execute().
        Specified by:
        setNoExplain in interface LazyCollection<E>
      • setBatchSize

        public void setBatchSize​(int size)
        Sets the number of rows requested from the ObjectStore whenever an execute call is made
        Specified by:
        setBatchSize in interface LazyCollection<E>
        Parameters:
        size - the number of rows
      • asList

        public java.util.List<E> asList()
        Return this Collection as a List. This may create a new ArrayList if necessary so the returned List is not guaranteed to be consistent if the LazyCollection changes.
        Specified by:
        asList in interface LazyCollection<E>
        Returns:
        a List
      • getMaterialisedCollection

        public java.util.Collection<E> getMaterialisedCollection()
        Gets the collection if it is a real materialised collection.
        Returns:
        a Collection
      • setMaterialisedCollection

        public void setMaterialisedCollection​(java.util.Collection<E> coll)
        Sets the collection with a new materialised collection.
        Parameters:
        coll - the new Collection
      • toString

        public java.lang.String toString()
        We override this here in order to prevent possible infinite recursion.
        Overrides:
        toString in class java.util.AbstractCollection<E>