Class ItemGroup

Direct Known Subclasses:
Collection, Folder

public abstract class ItemGroup extends Item
Abstract class encapsulating a Postman ItemGroup. This class provides services for recursively finding, adding and removing child elements, eg., a request in a folder.

Postman SDK analog: ItemGroup.

  • Constructor Details

    • ItemGroup

      public ItemGroup(String name)
  • Method Details

    • getItems

      public ArrayList<Item> getItems()
      Return an ArrayList<Item> containing the tree of items owned by this item. * @return ArrayList<Item> The items
    • getItems

      public ArrayList<Item> getItems(enumItemType filter)
      Recursively search the entire tree of items in the item property, optionally filter by item type (eg. FOLDER or REQUEST)
      Parameters:
      filter - Enumerated value for the object type, eg., FOLDER or REQUEST. Passing null returns all items.
      Returns:
    • setItems

      public void setItems(ArrayList<Item> items)
      Set the value of the item array with an ArrayList<Item>. Passing null effectively removes all children from this item.
      Parameters:
      items - The items, or null to remove all items.
    • getItem

      public Item getItem(String key)
      Recursively search the contents of the item array for the item with the specified key. Generally this is the name property for requests and folders.
      Parameters:
      key - The key (name) of the desired item
      Returns:
      Item The item, if it is found in the item array, or null if it is not.
    • getItem

      public Item getItem(String key, enumItemType filter)
      Recursively search the contents of the item array for the item with the specified key, optionally returning the item or it's parent item.
      Parameters:
      key - The key (name) of the desired item
      parent - True to return the parent of the item, if found, false to return the item itself.
      filter - Optional, filter on object type, eg., FOLDER or REQUEST. If null, do not filter
      Returns:
      Item The item if present, or null
    • addItems

      public void addItems(ArrayList<Item> newItems) throws RecursiveItemAddException, IllegalPropertyAccessException
      Add multiple items to this item.
      Parameters:
      newItems - The items to add
      Throws:
      RecursiveItemAddException
      IllegalPropertyAccessException
    • hasItem

      public boolean hasItem(Item theItem)
      Searches the direct children of this item (eg., non-recursively) to find an entry in the array that is the same Java instance as this item (Object.equals())
      Parameters:
      theItem - The item to search for
      Returns:
      boolean
    • addItem

      public void addItem(Item newItem) throws RecursiveItemAddException, IllegalPropertyAccessException
      Append a new direct child item to the array of items in the item property. This method does not recursively check for circular additions/references.
      Parameters:
      newItem - The item to add
      Throws:
      RecursiveItemAddException - If newItem is the same item instance as this item.
      IllegalPropertyAccessException - If this item is a request
    • addItem

      public void addItem(Item newItem, int position) throws IllegalPropertyAccessException, RecursiveItemAddException
      Add a new direct child item to the array of items in the item property at the specified index. This method does not recursively check for circular additions/references.
      Parameters:
      newItem - Item to add
      position - Index for new item
      Throws:
      IllegalPropertyAccessException - If newItem is already a direct child of this item, or if position is < 0 or > the size of the existing array
      RecursiveItemAddException - If newItem is already a child of this item
    • removeItem

      public void removeItem(Item oldItem)
      Removes an item from the tree of items comprising the item property
      Parameters:
      oldItem - The item to remove
    • removeItem

      public void removeItem(String key)
      Removes an item with the specified key from the tree of items comprising the item property
      Parameters:
      key - Key of the item to remove (ie. it's name)
    • getRequest

      public Request getRequest(String key)
    • getFolder

      public Folder getFolder(String key)