/** * Gets the closures. * * @return a copy of the closures * @since 3.1 */ public Closure<? super E>[] getClosures() { return FunctorUtils.<E>copy(iClosures); }
/** * Gets the predicates. * * @return a copy of the predicates * @since 3.1 */ public Predicate<? super I>[] getPredicates() { return FunctorUtils.<I>copy(iPredicates); }
/** * Gets the predicates. * * @return a copy of the predicates * @since 3.1 */ @Override public Predicate<? super T>[] getPredicates() { return FunctorUtils.<T>copy(iPredicates); }
/** * Gets the transformers. * * @return a copy of the transformers * @since 3.1 */ public Transformer<? super I, ? extends O>[] getTransformers() { return FunctorUtils.<I, O>copy(iTransformers); }
/** * Hidden constructor for the use by the static factory methods. * * @param clone if {@code true} the input argument will be cloned * @param transformers the transformers to chain, no nulls */ private ChainedTransformer(final boolean clone, final Transformer<? super T, ? extends T>[] transformers) { super(); iTransformers = clone ? FunctorUtils.copy(transformers) : transformers; }
/** * Hidden constructor for the use by the static factory methods. * * @param clone if {@code true} the input argument will be cloned * @param closures the closures to chain, no nulls */ private ChainedClosure(final boolean clone, final Closure<? super E>... closures) { super(); iClosures = clone ? FunctorUtils.copy(closures) : closures; }
/** * Gets the closures. * * @return a copy of the closures * @since 3.1 */ public Closure<? super E>[] getClosures() { return FunctorUtils.<E>copy(iClosures); }
/** * Gets the predicates. * * @return a copy of the predicates * @since 3.1 */ public Predicate<? super E>[] getPredicates() { return FunctorUtils.<E>copy(iPredicates); }
/** * Gets the transformers. * * @return a copy of the transformers * @since 3.1 */ public Transformer<? super T, ? extends T>[] getTransformers() { return FunctorUtils.<T, T>copy(iTransformers); }
/** * Hidden constructor for the use by the static factory methods. * * @param clone if {@code true} the input arguments will be cloned * @param predicates array of predicates, no nulls * @param closures matching array of closures, no nulls * @param defaultClosure the closure to use if no match, null means nop */ @SuppressWarnings("unchecked") private SwitchClosure(final boolean clone, final Predicate<? super E>[] predicates, final Closure<? super E>[] closures, final Closure<? super E> defaultClosure) { super(); iPredicates = clone ? FunctorUtils.copy(predicates) : predicates; iClosures = clone ? FunctorUtils.copy(closures) : closures; iDefault = (Closure<? super E>) (defaultClosure == null ? NOPClosure.<E>nopClosure() : defaultClosure); }
/** * Hidden constructor for the use by the static factory methods. * * @param clone if {@code true} the input arguments will be cloned * @param predicates array of predicates, no nulls * @param transformers matching array of transformers, no nulls * @param defaultTransformer the transformer to use if no match, null means return null */ @SuppressWarnings("unchecked") private SwitchTransformer(final boolean clone, final Predicate<? super I>[] predicates, final Transformer<? super I, ? extends O>[] transformers, final Transformer<? super I, ? extends O> defaultTransformer) { super(); iPredicates = clone ? FunctorUtils.copy(predicates) : predicates; iTransformers = clone ? FunctorUtils.copy(transformers) : transformers; iDefault = (Transformer<? super I, ? extends O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() : defaultTransformer); }
/** * Factory to create the predicate. * <p> * If the array is size zero, the predicate always returns true. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>any</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ public static <T> Predicate<T> nonePredicate(final Predicate<? super T>... predicates) { FunctorUtils.validate(predicates); if (predicates.length == 0) { return TruePredicate.<T>truePredicate(); } return new NonePredicate<>(FunctorUtils.copy(predicates)); }
/** * Factory to create the predicate. * <p> * If the array is size zero, the predicate always returns false. * If the array is size one, then that predicate is returned. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>any</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ @SuppressWarnings("unchecked") public static <T> Predicate<T> anyPredicate(final Predicate<? super T>... predicates) { FunctorUtils.validate(predicates); if (predicates.length == 0) { return FalsePredicate.<T>falsePredicate(); } if (predicates.length == 1) { return (Predicate<T>) predicates[0]; } return new AnyPredicate<>(FunctorUtils.copy(predicates)); }
/** * Factory to create the predicate. * <p> * If the array is size zero, the predicate always returns false. * If the array is size one, then that predicate is returned. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>any</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ @SuppressWarnings("unchecked") public static <T> Predicate<T> onePredicate(final Predicate<? super T>... predicates) { FunctorUtils.validate(predicates); if (predicates.length == 0) { return FalsePredicate.<T>falsePredicate(); } if (predicates.length == 1) { return (Predicate<T>) predicates[0]; } return new OnePredicate<>(FunctorUtils.copy(predicates)); }
/** * Factory to create the predicate. * <p> * If the array is size zero, the predicate always returns true. * If the array is size one, then that predicate is returned. * * @param <T> the type that the predicate queries * @param predicates the predicates to check, cloned, not null * @return the <code>all</code> predicate * @throws NullPointerException if the predicates array is null * @throws NullPointerException if any predicate in the array is null */ public static <T> Predicate<T> allPredicate(final Predicate<? super T>... predicates) { FunctorUtils.validate(predicates); if (predicates.length == 0) { return truePredicate(); } if (predicates.length == 1) { return coerce(predicates[0]); } return new AllPredicate<>(FunctorUtils.copy(predicates)); }