@SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") @Override public void addAction(@Nonnull Action a) { if (a == null) { throw new IllegalArgumentException("Action must be non-null"); } super.getActions().add(a); }
/** * Adds a new action. * Note: calls to {@link #getAllActions()} that happen before calls to this method may not see the update. * <strong>Note: this method will always modify the actions</strong> */ @SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void addAction(@Nonnull Action a) { if(a==null) { throw new IllegalArgumentException("Action must be non-null"); } getActions().add(a); }
/** * Remove an action. * Note: calls to {@link #getAllActions()} that happen before calls to this method may not see the update. * Note: this method does not affect transient actions contributed by a {@link TransientActionFactory} * Note: this method cannot provide concurrency control due to the backing storage being a * {@link CopyOnWriteArrayList} so concurrent calls to any of the mutation methods may produce surprising results * though technically consistent from the concurrency contract of {@link CopyOnWriteArrayList} (we would need * some form of transactions or a different backing type). * * @param a an action to remove (if {@code null} then this will be a no-op) * @return {@code true} if this actions changed as a result of the call * @since 2.29 */ @SuppressWarnings("deprecation") public boolean removeAction(@Nullable Action a) { if (a == null) { return false; } // CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way: return getActions().removeAll(Collections.singleton(a)); }
/** * Returns the transient {@link Action}s associated with the computer. */ @SuppressWarnings("deprecation") public List<Action> getActions() { List<Action> result = new ArrayList<Action>(); result.addAll(super.getActions()); synchronized (this) { if (transientActions == null) { transientActions = TransientComputerActionFactory.createAllFor(this); } result.addAll(transientActions); } return Collections.unmodifiableList(result); }
/** * Removes any actions of the specified type. * Note: calls to {@link #getAllActions()} that happen before calls to this method may not see the update. * Note: this method does not affect transient actions contributed by a {@link TransientActionFactory} * Note: this method cannot provide concurrency control due to the backing storage being a * {@link CopyOnWriteArrayList} so concurrent calls to any of the mutation methods may produce surprising results * though technically consistent from the concurrency contract of {@link CopyOnWriteArrayList} (we would need * some form of transactions or a different backing type). * * @param clazz the type of actions to remove * @return {@code true} if this actions changed as a result of the call * @since 2.29 */ @SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public boolean removeActions(@Nonnull Class<? extends Action> clazz) { if (clazz == null) { throw new IllegalArgumentException("Action type must be non-null"); } // CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way: List<Action> old = new ArrayList<Action>(); List<Action> current = getActions(); for (Action a : current) { if (clazz.isInstance(a)) { old.add(a); } } return current.removeAll(old); }
/** * Gets the action (first instance to be found) of a specified type that contributed to this build. * * @param type * @return The action or <code>null</code> if no such actions exist. * @see #getActions(Class) */ public <T extends Action> T getAction(Class<T> type) { // Shortcut: if the persisted list has one, return it. for (Action a : getActions()) { if (type.isInstance(a)) { return type.cast(a); } } // Otherwise check transient factories. for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), type)) { for (Action a : createFor(taf)) { if (type.isInstance(a)) { return type.cast(a); } } } return null; }
List<Action> current = getActions(); boolean found = false; for (Action a2 : current) {
List<Action> current = getActions(); boolean found = false; for (Action a1 : current) {
/** * Gets all actions, transient or persistent. * {@link #getActions} is supplemented with anything contributed by {@link TransientActionFactory}. * @return an unmodifiable, possible empty list * @since 1.548 */ @Exported(name="actions") @Nonnull public final List<? extends Action> getAllActions() { List<Action> _actions = getActions(); boolean adding = false; for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), Action.class)) { Collection<? extends Action> additions = createFor(taf); if (!additions.isEmpty()) { if (!adding) { // need to make a copy adding = true; _actions = new ArrayList<>(_actions); } _actions.addAll(additions); } } return Collections.unmodifiableList(_actions); }
/** * 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); }
/** * Adds a new action. * * Short for <tt>getActions().add(a)</tt> */ public void addAction(Action a) { if(a==null) throw new IllegalArgumentException(); getActions().add(a); }
/** * Gets the action (first instance to be found) of a specified type that contributed to this build. * * @param type * @return The action or <code>null</code> if no such actions exist. * @see #getActions(Class) */ public <T extends Action> T getAction(Class<T> type) { for (Action a : getActions()) if (type.isInstance(a)) return type.cast(a); return null; }
/** * Adds a new action. * * Short for <tt>getActions().add(a)</tt> */ public void addAction(Action a) { if(a==null) throw new IllegalArgumentException(); getActions().add(a); }
/** * Adds a new action. * * Short for <tt>getActions().add(a)</tt> */ public void addAction(Action a) { if (a == null) { throw new IllegalArgumentException(); } getActions().add(a); }
static Iterable<Trigger> triggersFor(Actionable actionable) { List<Trigger> triggers = new ArrayList<>(); for (BuildTriggerAction action : actionable.getActions(BuildTriggerAction.class)) { synchronized (action.triggers) { triggers.addAll(action.triggers); } } return triggers; }
/** * Adds a new action. * * Short for <tt>getActions().add(a)</tt> */ public void addAction(Action a) { if(a==null) throw new IllegalArgumentException(); getActions().add(a); }
@SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") @Override public void addAction(@Nonnull Action a) { if (a == null) { throw new IllegalArgumentException("Action must be non-null"); } super.getActions().add(a); }
public static <T extends Action> List<T> getPersistentActions(Actionable actionable, Class<T> type) { List<T> filtered = new LinkedList<>(); // we use this method to avoid recursively calling transitive action factories for (Action a : actionable.getActions()) { if (a == null) { continue; } if (type.isAssignableFrom(a.getClass())) { filtered.add((T) a); } } return filtered; }
/** * Gets all actions of a specified type that contributed to this build. * * @param type The type of action to return. * @return may be empty but never null. * @see #getAction(Class) */ public <T extends Action> List<T> getActions(Class<T> type) { List<T> result = new Vector<T>(); for (Action a : getActions()) { if (type.isInstance(a)) { result.add(type.cast(a)); } } return result; }
public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { for (Action a : getActions()) { if(a==null) continue; // be defensive String urlName = a.getUrlName(); if(urlName==null) continue; if(urlName.equals(token)) return a; } return null; } }