Class CollectionsHelper

java.lang.Object
wt.fc.collections.CollectionsHelper

public final class CollectionsHelper extends Object
Provides utility methods for dealing with WTCollections.

Supported API: true

Extendable: false
  • Method Details

    • getExcludedClasses

      public static List getExcludedClasses(WTCollection collection, Class base_class) throws WTException
      Get the list of known subclasses of the given base_class that do not have instances in the given collection. This list can then be used to set the excluded descendants on a TableExpression in order to optimize the number of tables a database query needs to hit.

      Supported API: true
      Parameters:
      collection -
      base_class -
      Returns:
      A list of Classes
      Throws:
      WTException
      See Also:
      • wt.query.AbstractTableExpression#setExcludedDescendants(List)
    • getNonPersistedSubSet

      public static WTSet getNonPersistedSubSet(WTCollection collection, boolean connect)
      Get a sub set of the objects in the given collection that are not persisted. The resulting WTSet is connected to the collection if connect is true. The resulting WTSet is never backed by the collection however -- so additions and removals to one are not reflected in the other.

      Supported API: true
      Parameters:
      collection -
      connect -
      Returns:
      A WTSet containing the non-persisted Persistables in this collection, or EMPTY_SET if there are none.
      See Also:
    • getPersistedSubSet

      public static WTSet getPersistedSubSet(WTCollection collection, boolean connect)
      Get a sub set of the objects in the given collection that are persisted. The resulting WTSet is connected to the collection if connect is true. The resulting WTSet is never backed by the collection however -- so additions and removals to one are not reflected in the other.

      Supported API: true
      Parameters:
      collection -
      connect -
      Returns:
      A WTSet containing the persisted Persistables in this collection, or EMPTY_SET if there are none.
      See Also:
    • inflate

      public static void inflate(WTCollection collection) throws WTException
      Inflate all elements in the collection that do not have an in-memory copy of their Persistable. Persistables that are already in the collection are not refreshed.

      Supported API: true
      Parameters:
      collection -
      Throws:
      WTException
    • inflate

      public static void inflate(WTKeyedMap map) throws WTException
      Inflate all elements in the map that do not have an in-memory copy of their Persistable. Persistables that are already in the map are not refreshed. If the map is an instanceof WTValuedMap, then both the keys and the values are inflated.

      Supported API: true
      Parameters:
      map -
      Throws:
      WTException
    • inflate

      public static void inflate(WTCollection collection, RefreshSpec spec) throws WTException
      Inflate all elements in the collection that do not have an in-memory copy of their Persistable. Use the given RefreshSpec to inflate the elements.

      Supported API: true
      Parameters:
      collection -
      spec -
      Throws:
      WTException
    • inflate

      public static void inflate(WTKeyedMap map, RefreshSpec spec) throws WTException
      Inflate all elements in the map that do not have an in-memory copy of their Persistable, with access control disabled.. Persistables that are already in the map are not refreshed. If the map is an instanceof WTValuedMap, then both the keys and the values are inflated. se the given RefreshSpec to inflate the elements.

      Supported API: true
      Parameters:
      map -
      spec -
      Throws:
      WTException
    • isInflated

      public static boolean isInflated(WTCollection collection)
      Determine if the given collection contains inflated objects. If the collection doesn't contain inflated objects, then calls to persistable-based APIs will require a trip to the server and possibly the database.

      Supported API: true
      Parameters:
      collection -
      Returns:
      true if this collection doesn't need to be inflated
    • synchronizedWTCollection

      public static WTCollection synchronizedWTCollection(WTCollection collection)


      Supported API: true
      Parameters:
      collection -
      Returns:
      WTCollection
    • synchronizedWTKeyedMap

      public static WTKeyedMap synchronizedWTKeyedMap(WTKeyedMap map)


      Supported API: true
      Parameters:
      map -
      Returns:
      WTKeyedMap
    • synchronizedWTList

      public static WTList synchronizedWTList(WTList list)


      Supported API: true
      Parameters:
      list -
      Returns:
      WTList
    • synchronizedWTSet

      public static WTSet synchronizedWTSet(WTSet set)


      Supported API: true
      Parameters:
      set -
      Returns:
      WTSet
    • synchronizedWTValuedMap

      public static WTValuedMap synchronizedWTValuedMap(WTValuedMap map)


      Supported API: true
      Parameters:
      map -
      Returns:
      WTValuedMap
    • unmodifiableWTCollection

      public static WTCollection unmodifiableWTCollection(WTCollection collection)


      Supported API: true
      Parameters:
      collection -
      Returns:
      WTCollection
    • unmodifiableWTKeyedMap

      public static WTKeyedMap unmodifiableWTKeyedMap(WTKeyedMap map)


      Supported API: true
      Parameters:
      map -
      Returns:
      WTKeyedMap
    • unmodifiableWTList

      public static WTList unmodifiableWTList(WTList list)


      Supported API: true
      Parameters:
      list -
      Returns:
      WTList
    • unmodifiableWTSet

      public static WTSet unmodifiableWTSet(WTSet set)


      Supported API: true
      Parameters:
      set -
      Returns:
      WTSet
    • unmodifiableWTValuedMap

      public static WTValuedMap unmodifiableWTValuedMap(WTValuedMap map)


      Supported API: true
      Parameters:
      map -
      Returns:
      WTValuedMap
    • validate

      public static void validate(WTCollection collection, Class filter)
      Ensures that all the objects in the given collection are instances of the given filter class.

      Supported API: true
      Parameters:
      collection -
      filter -
      Throws:
      ClassCastException - If the filter is not assignable from the class of at least one of the objects in the collection
    • singletonWTSet

      public static WTSet singletonWTSet(Object o)
      Returns an immutable WTSet containing only the specified object.

      Supported API: true
      Parameters:
      o - The sole object to be stored in the returned WTSet.
      Returns:
      An immutable WTSet containing only the specified object.
    • singletonWTList

      public static WTList singletonWTList(Object o)
      Returns an immutable WTList containing only the specified object.

      Supported API: true
      Parameters:
      o - The sole object to be stored in the returned WTList.
      Returns:
      An immutable WTList containing only the specified object.
    • singletonWTKeyedMap

      public static WTKeyedMap singletonWTKeyedMap(Object key, Object value)
      Returns an immutable WTKeyedMap, mapping only the specified key to the specified value.

      Supported API: true
      Parameters:
      key - The sole key to be stored in the returned WTKeyedMap.
      value - The value to which the returned WTKeyedMap maps key.
      Returns:
      An immutable WTKeyedMap containing only the specified key-value mapping.
    • singletonWTValuedMap

      public static WTValuedMap singletonWTValuedMap(Object key, Object value)
      Returns an immutable WTValuedMap, mapping only the specified key to the specified value.

      Supported API: true
      Parameters:
      key - The sole key to be stored in the returned WTValuedMap.
      value - The value to which the returned WTValuedMap maps key.
      Returns:
      An immutable WTValuedMap containing only the specified key-value mapping.