MCPcopy Create free account
hub / github.com/EsperoTech/yaade / ItemGroup

Class ItemGroup

server/src/main/java/com/postman/collection/ItemGroup.java:21–291  ·  view source on GitHub ↗

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 .

Source from the content-addressed store, hash-verified

19 */
20
21public abstract class ItemGroup extends Item {
22 private ArrayList<Item> item;
23
24
25 /**
26 *
27 * Return an ArrayList&#60;{@link com.postman.collection.Item Item}&#62; containing the tree of items owned by this item.
28 *
29 * * @return ArrayList&#60;{@link com.postman.collection.Item Item}&#62; 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 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected