Package com.postman.collection
Class ItemGroup
java.lang.Object
com.postman.collection.CollectionElement
com.postman.collection.Item
com.postman.collection.ItemGroup
- Direct Known Subclasses:
Collection
,Folder
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Append a new direct child item to the array of items in theitem
property.void
Add a new direct child item to the array of items in theitem
property at the specified index.void
Add multiple items to this item.Recursively search the contents of theitem
array for the item with the specified key.getItem
(String key, enumItemType filter) Recursively search the contents of theitem
array for the item with the specified key, optionally returning the item or it's parent item.getItems()
Return an ArrayList<Item
> containing the tree of items owned by this item.getItems
(enumItemType filter) Recursively search the entire tree of items in theitem
property, optionally filter by item type (eg.getRequest
(String key) boolean
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())void
removeItem
(Item oldItem) Removes an item from the tree of items comprising theitem
propertyvoid
removeItem
(String key) Removes an item with the specified key from the tree of items comprising theitem
propertyvoid
Set the value of theitem
array with an ArrayList<Item>.Methods inherited from class com.postman.collection.Item
getDescription, getEvent, getEvents, getKey, getName, getParent, getPreRequestScript, getTestScript, setDescription, setEvents, setName, setParent, setPreRequestScript, setTestScript
Methods inherited from class com.postman.collection.CollectionElement
getCollection, getDefaultCollectionSchema, getDefaultValidationSchema, getUUID, getValidationMessages, isEquivalentTo, setParent, setUUID, toJson, toJson, validate, validate
-
Constructor Details
-
ItemGroup
-
-
Method Details
-
getItems
-
getItems
Recursively search the entire tree of items in theitem
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
Set the value of theitem
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
Recursively search the contents of theitem
array for the item with the specified key. Generally this is thename
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
Recursively search the contents of theitem
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 itemparent
- 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
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
Append a new direct child item to the array of items in theitem
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 theitem
property at the specified index. This method does not recursively check for circular additions/references.- Parameters:
newItem
- Item to addposition
- 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 arrayRecursiveItemAddException
- If newItem is already a child of this item
-
removeItem
Removes an item from the tree of items comprising theitem
property- Parameters:
oldItem
- The item to remove
-
removeItem
Removes an item with the specified key from the tree of items comprising theitem
property- Parameters:
key
- Key of the item to remove (ie. it's name)
-
getRequest
-
getFolder
-