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 .
| 19 | */ |
| 20 | |
| 21 | public abstract class ItemGroup extends Item { |
| 22 | private ArrayList<Item> item; |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * |
| 27 | * Return an ArrayList<{@link com.postman.collection.Item Item}> containing the tree of items owned by this item. |
| 28 | * |
| 29 | * * @return ArrayList<{@link com.postman.collection.Item Item}> The items |
| 30 | */ |
| 31 | public ArrayList<Item> getItems() { |
| 32 | return item; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * |
| 37 | * Recursively search the entire tree of items in the <code>item</code> property, optionally filter by item type (eg. FOLDER or REQUEST) |
| 38 | * |
| 39 | * |
| 40 | * @param filter Enumerated value for the object type, eg., FOLDER or REQUEST. Passing null returns all items. |
| 41 | * @return |
| 42 | */ |
| 43 | public ArrayList<Item> getItems(enumItemType filter) { |
| 44 | ArrayList<Item> results = new ArrayList<Item>(); |
| 45 | |
| 46 | if (item == null) { |
| 47 | return null; |
| 48 | } |
| 49 | |
| 50 | for (Item curItem : item) { |
| 51 | if(filter == null && !(curItem instanceof ItemGroup) ) { |
| 52 | results.add(curItem); |
| 53 | } |
| 54 | else if(filter == null && curItem instanceof ItemGroup) { |
| 55 | results.addAll(((ItemGroup)curItem).getItems(filter)); |
| 56 | } |
| 57 | else if (filter != null && curItem instanceof Folder) { |
| 58 | if(filter == enumItemType.FOLDER) { |
| 59 | results.add(curItem); |
| 60 | } |
| 61 | try { |
| 62 | results.addAll(((Folder)curItem).getItems(filter)); |
| 63 | |
| 64 | } catch (Exception e) { |
| 65 | e.printStackTrace(); |
| 66 | } |
| 67 | } |
| 68 | else if((filter != null && filter == enumItemType.REQUEST && curItem instanceof Request)) { |
| 69 | results.add(curItem); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | } |
| 74 | |
| 75 | return results; |
| 76 | } |
| 77 | |
| 78 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected