/** * 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; }
/** * 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); }
/** * 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; }
/** * 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); }