Package com.im.df.api.ddl
Class DFItems
- java.lang.Object
-
- com.im.df.api.ddl.DFItems
-
public final class DFItems extends java.lang.Object
Common utilities related toDFItem
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DFItems.Functions
Functions related toDFItem
s.static class
DFItems.Predicates
Predicates related toDFItem
s.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends DFItem>
java.util.List<T>alphabeticallySortedCopy(java.lang.Iterable<T> items)
Returns alphabetically sorted copy of the given items by their names, ignoring case differences.static <T extends DFItem>
TfindItemById(java.lang.Iterable<T> items, java.lang.String id)
Finds aDFItem
by its ID.static <T extends DFItem>
java.lang.Iterable<T>findItemsByIds(java.lang.Iterable<T> items, java.lang.Iterable<? extends java.lang.String> ids)
FindsDFItem
s with specific IDs.static <T extends DFItem>
java.lang.Iterable<T>findItemsByIds(java.lang.Iterable<T> items, java.lang.String... ids)
FindsDFItem
s with specific IDs.static <T extends DFItem,C extends DFCapability>
java.util.List<T>findItemsWithCapability(java.util.List<T> items, java.lang.Class<C> capabilityClass)
Filter the specified items so that only those with the specified capability are returned.static <T extends DFItem>
voidonInvalidate(T item, com.im.commons.Callback<? super T> callback)
Registers the callback to be performed on item invalidation.static void
prettyPrint(DFContainer<? extends DFItem> items)
CallsprettyPrint(DFContainer, boolean)
with second parameter asfalse
.static void
prettyPrint(DFContainer<? extends DFItem> items, boolean details)
Utility method supposed to be used during IJC development only.
-
-
-
Method Detail
-
onInvalidate
public static <T extends DFItem> void onInvalidate(T item, com.im.commons.Callback<? super T> callback)
Registers the callback to be performed on item invalidation. The callback will be run only once. If the item is already invalid, the callback is run immediately in the current thread and an exception is logged. This is a convenience feature because most of the client code shouldn't access invalid DFItems.Note that the callback will be held by the item in a regular reference so any objects referenced by it can't be GC'd earlier than the item.
- Type Parameters:
T
- type of the invalidated item- Parameters:
item
- item to watchcallback
- user callback- Since:
- 14.10.20
-
findItemById
public static <T extends DFItem> T findItemById(java.lang.Iterable<T> items, java.lang.String id)
Finds aDFItem
by its ID.- Type Parameters:
T
- The type of items to search through.- Parameters:
items
- The items to search through.id
- The ID of an item to find.- Returns:
- The item from
items
, which has itsID
equal to theid
parameter. - Since:
- 6.3
-
findItemsByIds
public static <T extends DFItem> java.lang.Iterable<T> findItemsByIds(java.lang.Iterable<T> items, java.lang.String... ids)
FindsDFItem
s with specific IDs.- Type Parameters:
T
- The type of items to search through.- Parameters:
items
- The items to search through.ids
- The IDs of items to find.- Returns:
- All items from the
items
iterable, which have their IDs specified in theids
parameter. - Since:
- 6.3
-
findItemsByIds
public static <T extends DFItem> java.lang.Iterable<T> findItemsByIds(java.lang.Iterable<T> items, java.lang.Iterable<? extends java.lang.String> ids)
FindsDFItem
s with specific IDs.- Type Parameters:
T
- The type of items to search through.- Parameters:
items
- The items to search through.ids
- The IDs of items to find.- Returns:
- All items from the
items
iterable, which have their IDs specified in theids
parameter. - Since:
- 6.3
-
findItemsWithCapability
public static <T extends DFItem,C extends DFCapability> java.util.List<T> findItemsWithCapability(java.util.List<T> items, java.lang.Class<C> capabilityClass)
Filter the specified items so that only those with the specified capability are returned.- Type Parameters:
T
- type of the itemsC
- type of the capability- Parameters:
items
- the items to look atcapabilityClass
- the required capability- Returns:
- the items with that capability
-
alphabeticallySortedCopy
public static <T extends DFItem> java.util.List<T> alphabeticallySortedCopy(java.lang.Iterable<T> items)
Returns alphabetically sorted copy of the given items by their names, ignoring case differences.- Type Parameters:
T
- type of the items- Parameters:
items
- unsorted items- Returns:
- sorted list
-
prettyPrint
public static void prettyPrint(DFContainer<? extends DFItem> items)
CallsprettyPrint(DFContainer, boolean)
with second parameter asfalse
. Be sure to read the Javadoc there.- Parameters:
items
- container with items
-
prettyPrint
public static void prettyPrint(DFContainer<? extends DFItem> items, boolean details)
Utility method supposed to be used during IJC development only. It is handy in cases you want to dumpDFContainer
to standard output.Example usage:
DFSchema schema = ... DFItems.prettyPrint(schema.getDataTrees()); ... DFEntity entity = ... DFItems.prettyPrint(entity.getFields());
Note: this method is not considered stable API and might be removed at any time. More generic solution is being considered instead. So use this only during development.- Parameters:
items
- container with itemsdetails
- should I be more verbose?
-
-