/** * Gets all the {@link Item}s recursively in the {@link ItemGroup} tree * and filter them by the given type. * @since 2.93 */ default <T extends Item> List<T> getAllItems(Class<T> type) { return Items.getAllItems(this, type); }
/** * Gets all the {@link Item}s recursively in the {@link ItemGroup} tree * and filter them by the given type. The returned list will represent a snapshot view of the items present at some * time during the call. If items are moved during the call, depending on the move, it may be possible for some * items to escape the snapshot entirely. * <p> * If you do not need to iterate all items, or if the order of the items is not required, consider using * {@link #allItems(ItemGroup, Class)} instead. * * @since 1.512 */ public static <T extends Item> List<T> getAllItems(final ItemGroup root, Class<T> type) { List<T> r = new ArrayList<T>(); getAllItems(root, type, r); return r; } private static <T extends Item> void getAllItems(final ItemGroup root, Class<T> type, List<T> r) {
private static <T extends Item> void getAllItems(final ItemGroup root, Class<T> type, List<T> r) { List<Item> items = new ArrayList<Item>(((ItemGroup<?>) root).getItems()); // because we add items depth first, we can use the quicker BY_NAME comparison Collections.sort(items, BY_NAME); for (Item i : items) { if (type.isInstance(i)) { if (i.hasPermission(Item.READ)) { r.add(type.cast(i)); } } if (i instanceof ItemGroup) { getAllItems((ItemGroup) i, type, r); } } }
/** * Gets all the {@link TopLevelItem}s recursively in the {@link ItemGroup} tree. * * @since 1.512 */ public static List<TopLevelItem> getAllTopLevelItems(ItemGroup root) { return Items.getAllItems(root, TopLevelItem.class); }
/** * Gets all the {@link Item}s recursively in the {@link ItemGroup} tree * and filter them by the given type. */ public <T extends Item> List<T> getAllItems(Class<T> type) { return Items.getAllItems(this, type); }
/** * Gets all the {@link Item}s recursively in the {@link ItemGroup} tree * and filter them by the given type. The returned list will represent a snapshot view of the items present at some * time during the call. If items are moved during the call, depending on the move, it may be possible for some * items to escape the snapshot entirely. * <p> * If you do not need to iterate all items, or if the order of the items is not required, consider using * {@link #allItems(ItemGroup, Class)} instead. * * @since 1.512 */ public static <T extends Item> List<T> getAllItems(final ItemGroup root, Class<T> type) { List<T> r = new ArrayList<T>(); getAllItems(root, type, r); return r; } private static <T extends Item> void getAllItems(final ItemGroup root, Class<T> type, List<T> r) {
/** * {@inheritDoc} */ @Override protected Collection<TopLevelItem> all() { return Items.getAllItems(grp(), TopLevelItem.class); }
/** * {@inheritDoc} */ @Override protected Collection<TopLevelItem> all() { return Items.getAllItems(grp(), TopLevelItem.class); }
private static <T extends Item> void getAllItems(final ItemGroup root, Class<T> type, List<T> r) { List<Item> items = new ArrayList<Item>(((ItemGroup<?>) root).getItems()); // because we add items depth first, we can use the quicker BY_NAME comparison Collections.sort(items, BY_NAME); for (Item i : items) { if (type.isInstance(i)) { if (i.hasPermission(Item.READ)) { r.add(type.cast(i)); } } if (i instanceof ItemGroup) { getAllItems((ItemGroup) i, type, r); } } }
public Collection<TopLevelItem> getItems(ItemGroup<? extends TopLevelItem> itemGroup) { SortedSet<String> names = new TreeSet<String>(jobNames); if (includePattern != null) { for (TopLevelItem item : Items.getAllItems(itemGroup, TopLevelItem.class)) { String itemName = item.getRelativeNameFrom(itemGroup); if (includePattern.matcher(itemName).matches()) { names.add(itemName); } } } List<TopLevelItem> items = new ArrayList<TopLevelItem>(names.size()); for (String n : names) { TopLevelItem item = Jenkins.getInstance().getItem(n, itemGroup, TopLevelItem.class); if(item!=null) items.add(item); } // check the filters Iterable<ViewJobFilter> jobFilters = getJobFilters(); List<TopLevelItem> allItems = new ArrayList<TopLevelItem>(itemGroup.getItems()); for (ViewJobFilter jobFilter: jobFilters) { items = jobFilter.filter(items, allItems, null); } return items; }
Iterable<? extends TopLevelItem> candidates; if (recurse) { candidates = Items.getAllItems(parent, TopLevelItem.class); } else { candidates = parent.getItems();
jobs = Items.getAllItems((ModifiableTopLevelItemGroup) item, TopLevelItem.class);
for (TopLevelItem item : Items.getAllItems(group, TopLevelItem.class)) { String escapedName = item.getRelativeNameFrom(group).replaceAll("\\.", "_"); if (formData.containsKey(escapedName) && formData.getBoolean(escapedName))
@Restricted(NoExternalUse.class) // for cc.xml.jelly public static Collection<TopLevelItem> getCCItems(View v) { if (Stapler.getCurrentRequest().getParameter("recursive") != null) { return Items.getAllItems(v.getOwner().getItemGroup(), TopLevelItem.class); } else { return v.getItems(); } }
Iterable<? extends TopLevelItem> items; if (recurse) { items = Items.getAllItems(getOwner().getItemGroup(), TopLevelItem.class); } else { items = getOwner().getItemGroup().getItems();