Package wt.fc.collections
Class CollectionsHelper
java.lang.Object
wt.fc.collections.CollectionsHelper
Provides utility methods for dealing with
Supported API: true
Extendable: false
WTCollections.
Supported API: true
Extendable: false
-
Method Summary
Modifier and TypeMethodDescriptionstatic ListgetExcludedClasses(WTCollection collection, Class base_class) Get the list of known subclasses of the given base_class that do not have instances in the given collection.static WTSetgetNonPersistedSubSet(WTCollection collection, boolean connect) Get a sub set of the objects in the given collection that are not persisted.static WTSetgetPersistedSubSet(WTCollection collection, boolean connect) Get a sub set of the objects in the given collection that are persisted.static voidinflate(WTCollection collection) Inflate all elements in the collection that do not have an in-memory copy of their Persistable.static voidinflate(WTCollection collection, RefreshSpec spec) Inflate all elements in the collection that do not have an in-memory copy of their Persistable.static voidinflate(WTKeyedMap map) Inflate all elements in the map that do not have an in-memory copy of their Persistable.static voidinflate(WTKeyedMap map, RefreshSpec spec) Inflate all elements in the map that do not have an in-memory copy of their Persistable, with access control disabled..static booleanisInflated(WTCollection collection) Determine if the given collection contains inflated objects.static WTKeyedMapsingletonWTKeyedMap(Object key, Object value) Returns an immutable WTKeyedMap, mapping only the specified key to the specified value.static WTListReturns an immutable WTList containing only the specified object.static WTSetReturns an immutable WTSet containing only the specified object.static WTValuedMapsingletonWTValuedMap(Object key, Object value) Returns an immutable WTValuedMap, mapping only the specified key to the specified value.static WTCollectionsynchronizedWTCollection(WTCollection collection)
Supported API: truestatic WTKeyedMap
Supported API: truestatic WTListsynchronizedWTList(WTList list)
Supported API: truestatic WTSetsynchronizedWTSet(WTSet set)
Supported API: truestatic WTValuedMap
Supported API: truestatic WTCollectionunmodifiableWTCollection(WTCollection collection)
Supported API: truestatic WTKeyedMap
Supported API: truestatic WTListunmodifiableWTList(WTList list)
Supported API: truestatic WTSetunmodifiableWTSet(WTSet set)
Supported API: truestatic WTValuedMap
Supported API: truestatic voidvalidate(WTCollection collection, Class filter) Ensures that all the objects in the given collection are instances of the given filter class.
-
Method Details
-
getExcludedClasses
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 aTableExpressionin 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
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
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
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
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
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
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
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
Supported API: true- Parameters:
collection-- Returns:
- WTCollection
-
synchronizedWTKeyedMap
Supported API: true- Parameters:
map-- Returns:
- WTKeyedMap
-
synchronizedWTList
Supported API: true- Parameters:
list-- Returns:
- WTList
-
synchronizedWTSet
Supported API: true- Parameters:
set-- Returns:
- WTSet
-
synchronizedWTValuedMap
Supported API: true- Parameters:
map-- Returns:
- WTValuedMap
-
unmodifiableWTCollection
Supported API: true- Parameters:
collection-- Returns:
- WTCollection
-
unmodifiableWTKeyedMap
Supported API: true- Parameters:
map-- Returns:
- WTKeyedMap
-
unmodifiableWTList
Supported API: true- Parameters:
list-- Returns:
- WTList
-
unmodifiableWTSet
Supported API: true- Parameters:
set-- Returns:
- WTSet
-
unmodifiableWTValuedMap
Supported API: true- Parameters:
map-- Returns:
- WTValuedMap
-
validate
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
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
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
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
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.
-