Class DFItems


  • public final class DFItems
    extends java.lang.Object
    Common utilities related to DFItem.
    • 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>
      T
      findItemById​(java.lang.Iterable<T> items, java.lang.String id)
      Finds a DFItem 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)
      Finds DFItems with specific IDs.
      static <T extends DFItem>
      java.lang.Iterable<T>
      findItemsByIds​(java.lang.Iterable<T> items, java.lang.String... ids)
      Finds DFItems 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>
      void
      onInvalidate​(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)
      Calls prettyPrint(DFContainer, boolean) with second parameter as false.
      static void prettyPrint​(DFContainer<? extends DFItem> items, boolean details)
      Utility method supposed to be used during IJC development only.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 watch
        callback - user callback
        Since:
        14.10.20
      • findItemById

        public static <T extends DFItem> T findItemById​(java.lang.Iterable<T> items,
                                                        java.lang.String id)
        Finds a DFItem 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 its ID equal to the id parameter.
        Since:
        6.3
      • findItemsByIds

        public static <T extends DFItem> java.lang.Iterable<T> findItemsByIds​(java.lang.Iterable<T> items,
                                                                              java.lang.String... ids)
        Finds DFItems 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 the ids 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)
        Finds DFItems 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 the ids 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 items
        C - type of the capability
        Parameters:
        items - the items to look at
        capabilityClass - 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,
                                       boolean details)
        Utility method supposed to be used during IJC development only. It is handy in cases you want to dump DFContainer 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 items
        details - should I be more verbose?