Class ItemUtils

java.lang.Object
dev.metaschema.core.metapath.item.ItemUtils

public final class ItemUtils extends Object
Provides a variety of utilities for working with Metapath items.
  • Method Details

    • checkItemIsNodeItem

      @NonNull public static INodeItem checkItemIsNodeItem(@NonNull DynamicContext dynamicContext, @Nullable IItem item)
      Checks that the item is an INodeItem.
      Parameters:
      dynamicContext - the dynamic evaluation context
      item - the item to check
      Returns:
      the item cast to a INodeItem
      Throws:
      TypeMetapathException - if the item is null or not an INodeItem
    • checkItemIsDocumentNodeItem

      @NonNull public static IDocumentBasedNodeItem checkItemIsDocumentNodeItem(@NonNull DynamicContext dynamicContext, @Nullable IItem item)
      Checks that the item is an IDocumentNodeItem.
      Parameters:
      dynamicContext - the dynamic evaluation context
      item - the item to check
      Returns:
      the item cast to a INodeItem
      Throws:
      TypeMetapathException - if the item is null or not an INodeItem
    • getDocumentNodeItems

      @NonNull public static ISequence<IDocumentBasedNodeItem> getDocumentNodeItems(@NonNull DynamicContext dynamicContext, @NonNull ISequence<?> items)
      Get the ancestor document nodes for the provided items.

      The resulting sequence has items of the IDocumentBasedNodeItem to allow for both module and document querying.

      Parameters:
      dynamicContext - the dynamic evaluation context
      items - the node items to get the document roots for
      Returns:
      the document root node items
    • checkItemType

      @NonNull public static <TYPE> TYPE checkItemType(@NonNull IItem item, @NonNull Class<TYPE> clazz)
      Check that the item is the type specified by clazz.
      Type Parameters:
      TYPE - the Java type the item is required to match
      Parameters:
      item - the item to check
      clazz - the Java class to check the item against
      Returns:
      the item cast to the required class value
      Throws:
      TypeMetapathException - if the item is null or does not match the type specified by clazz