/** * Creates a filtered sublist. */ @Nonnull public static <T> List<T> filter( @Nonnull List<?> base, @Nonnull Class<T> type ) { return filter((Iterable)base,type); }
/** * Allow an other build of the same project to be scheduled, if it has other parameters. */ public boolean shouldSchedule(List<Action> actions) { List<ParametersAction> others = Util.filter(actions, ParametersAction.class); if (others.isEmpty()) { return !parameters.isEmpty(); } else { // I don't think we need multiple ParametersActions, but let's be defensive Set<ParameterValue> params = new HashSet<ParameterValue>(); for (ParametersAction other: others) { params.addAll(other.parameters); } return !params.equals(new HashSet<ParameterValue>(this.parameters)); } }
/** * Gets the snapshot of {@link Runner}s that are performing polling. */ public List<Runner> getRunners() { return Util.filter(queue.getInProgress(),Runner.class); }
@Override protected Set<ResourceActivity> getResourceActivities() { final Set<ResourceActivity> activities = new HashSet<ResourceActivity>(); activities.addAll(super.getResourceActivities()); activities.addAll(Util.filter(getBuildersList(),ResourceActivity.class)); activities.addAll(Util.filter(getPublishersList(),ResourceActivity.class)); activities.addAll(Util.filter(getBuildWrappersList(),ResourceActivity.class)); return activities; }
/** * Gets all actions of a specified type that contributed to this object. * * @param type The type of action to return. * @return an unmodifiable, possible empty list * @see #getAction(Class) */ @Nonnull public <T extends Action> List<T> getActions(Class<T> type) { List<T> _actions = Util.filter(getActions(), type); for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), type)) { _actions.addAll(Util.filter(createFor(taf), type)); } return Collections.unmodifiableList(_actions); }
private List<TopLevelItem> expand(Collection<TopLevelItem> items, List<TopLevelItem> allItems) { for (TopLevelItem item : items) { if (item instanceof ItemGroup) { ItemGroup<? extends Item> ig = (ItemGroup<? extends Item>) item; expand(Util.filter(ig.getItems(), TopLevelItem.class), allItems); } allItems.add(item); } return allItems; }
/** * Finds a resolved method annotated with {@link CLIResolver}. */ private Method findResolver(Class type) throws IOException { List<Method> resolvers = Util.filter(Index.list(CLIResolver.class, Jenkins.get().getPluginManager().uberClassLoader), Method.class); for ( ; type!=null; type=type.getSuperclass()) for (Method m : resolvers) if (m.getReturnType()==type) return m; return null; }
@CheckForNull Queue.Item scheduleBuild2(int quietPeriod, List<Action> actions) { if (!asJob().isBuildable()) return null; List<Action> queueActions = new ArrayList<Action>(actions); if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) { queueActions.add(new ParametersAction(getDefaultParametersValues())); } return Jenkins.getInstance().getQueue().schedule2(asJob(), quietPeriod, queueActions).getItem(); }
/** * If any of the peephole permalink points to the build to be deleted, update it to point to the new location. */ @Override public void onDeleted(Run run) { Job<?, ?> j = run.getParent(); for (PeepholePermalink pp : Util.filter(j.getPermalinks(), PeepholePermalink.class)) { if (pp.resolve(j)==run) { Run<?,?> r = pp.find(run.getPreviousBuild()); if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Updating "+pp.getPermalinkFile(j).getName()+" permalink from deleted "+run.getNumber()+" to "+(r == null ? -1 : r.getNumber())); pp.updateCache(j,r); } } }
/** * See if the new build matches any of the peephole permalink. */ @Override public void onCompleted(Run<?,?> run, @Nonnull TaskListener listener) { Job<?, ?> j = run.getParent(); for (PeepholePermalink pp : Util.filter(j.getPermalinks(), PeepholePermalink.class)) { if (pp.apply(run)) { Run<?, ?> cur = pp.resolve(j); if (cur==null || cur.getNumber()<run.getNumber()) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Updating "+pp.getPermalinkFile(j).getName()+" permalink to completed "+run.getNumber()); pp.updateCache(j,run); } } } } }
for ( final Method m : Util.filter(Index.list(CLIMethod.class, jenkins.getPluginManager().uberClassLoader),Method.class)) { try {
shouldScheduleItem |= action.shouldSchedule(actions); for (QueueAction action : Util.filter(actions, QueueAction.class)) { shouldScheduleItem |= action.shouldSchedule((new ArrayList<Action>(item.getAllActions()))); for (FoldableAction a : Util.filter(actions, FoldableAction.class)) { a.foldIntoExisting(item, p, actions); if (LOGGER.isLoggable(Level.FINE)) { for (WaitingItem wi : Util.filter(duplicatesInQueue, WaitingItem.class)) {
/** * Gets the snapshot of {@link Runner}s that are performing polling. */ public List<Runner> getRunners() { return Util.filter(queue.getInProgress(),Runner.class); }
/** * Creates a subset of the list that only contains the type assignable to the specified type. */ public AxisList subList(Class<? extends Axis> subType) { return new AxisList(Util.filter(this,subType)); }
/** * Creates a subset of the list that only contains the type assignable to the specified type. */ public AxisList subList(Class<? extends Axis> subType) { return new AxisList(Util.filter(this,subType)); }
/** * Creates a subset of the list that only contains the type assignable to the specified type. */ public AxisList subList(Class<? extends Axis> subType) { return new AxisList(Util.filter(this,subType)); }
private List<TopLevelItem> expand(Collection<TopLevelItem> items, List<TopLevelItem> allItems) { for (TopLevelItem item : items) { if (item instanceof ItemGroup) { ItemGroup<? extends Item> ig = (ItemGroup<? extends Item>) item; expand(Util.filter(ig.getItems(), TopLevelItem.class), allItems); } allItems.add(item); } return allItems; }
/** * Finds a resolved method annotated with {@link CLIResolver}. */ private Method findResolver(Class type) throws IOException { List<Method> resolvers = Util.filter(Index.list(CLIResolver.class, Hudson.getInstance().getPluginManager().uberClassLoader), Method.class); for ( ; type!=null; type=type.getSuperclass()) for (Method m : resolvers) if (m.getReturnType()==type) return m; return null; }
protected void scheduleSubBuilds(final Iterable<Combination> subBuildCombinations, final SubBuildFinishListener subBuildFinishListener, final TaskListener listener) { for (final Combination subBuildCombination : subBuildCombinations) { final DynamicSubProject c = this.dynamicBuild.getSubProject(subBuildCombination); listener.getLogger().println(Messages.MatrixBuild_Triggering(ModelHyperlinkNote.encodeTo(c))); final List<Action> childActions = new ArrayList<>(); childActions.addAll(Util.filter(this.dynamicBuild.getActions(), ParametersAction.class)); childActions.add(new SubBuildExecutionAction(this.subBuildRunner, subBuildFinishListener)); childActions.add(new ParentBuildAction(this.dynamicBuild)); c.scheduleBuild(childActions, this.dynamicBuild.getCause()); } }
@CheckForNull Queue.Item scheduleBuild2(int quietPeriod, List<Action> actions) { if (!asJob().isBuildable()) return null; List<Action> queueActions = new ArrayList<Action>(actions); if (isParameterized() && Util.filter(queueActions, ParametersAction.class).isEmpty()) { queueActions.add(new ParametersAction(getDefaultParametersValues())); } return Jenkins.getInstance().getQueue().schedule2(asJob(), quietPeriod, queueActions).getItem(); }