diff options
5 files changed, 20 insertions, 13 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AND.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AND.java index 037a3868f9..ef2ba8c87f 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AND.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AND.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 Oracle. All rights reserved. + * Copyright (c) 2005, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -32,6 +32,7 @@ public class AND<V> * Construct a predicate that will evaluate to <code>true</code> if <em>all</em> * the specified predicates evaluate to <code>true</code>. */ + @SafeVarargs public AND(Predicate<? super V>... predicates) { super(predicates); } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AbstractCompoundPredicate.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AbstractCompoundPredicate.java index 3d11783697..b6af083d8d 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AbstractCompoundPredicate.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/AbstractCompoundPredicate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 Oracle. All rights reserved. + * Copyright (c) 2005, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -24,12 +24,13 @@ import org.eclipse.jpt.common.utility.predicate.Predicate; public abstract class AbstractCompoundPredicate<V> implements CompoundPredicate<V> { - protected Predicate<? super V>[] predicates; + protected final Predicate<? super V>[] predicates; /** * Construct a compound predicate for the specified list of predicates. */ + @SafeVarargs protected AbstractCompoundPredicate(Predicate<? super V>... predicates) { super(); if (ArrayTools.isOrContainsNull(predicates)) { @@ -66,13 +67,14 @@ public abstract class AbstractCompoundPredicate<V> StringBuilderTools.appendHashCodeToString(sb, this); sb.append('('); if (this.predicates.length > 0) { + String operatorString = this.operatorString(); for (Predicate<? super V> predicate : this.predicates) { sb.append(predicate); sb.append(' '); - sb.append(this.operatorString()); + sb.append(operatorString); sb.append(' '); } - sb.setLength(sb.length() - this.operatorString().length() - 2); + sb.setLength(sb.length() - operatorString.length() - 2); } sb.append(')'); return sb.toString(); diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/OR.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/OR.java index ca9d794ed1..80224723be 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/OR.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/OR.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 Oracle. All rights reserved. + * Copyright (c) 2005, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -32,6 +32,7 @@ public class OR<V> * Construct a predicate that will evaluate to <code>true</code> if <em>any</em> * the specified predicates evaluates to <code>true</code>. */ + @SafeVarargs public OR(Predicate<? super V>... predicates) { super(predicates); } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/PredicateTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/PredicateTools.java index 18a186e212..9f66583d32 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/PredicateTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/PredicateTools.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Oracle. All rights reserved. + * Copyright (c) 2013, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -115,13 +115,14 @@ public final class PredicateTools { */ @SuppressWarnings("unchecked") public static <V> CompoundPredicate<V> and(Iterator<Predicate<? super V>> predicates) { - return and(IteratorTools.toArray(predicates, EMPTY_ARRAY)); + return and((Predicate<? super V>[]) IteratorTools.toArray(predicates, EMPTY_ARRAY)); } /** * Return a predicate that will AND the results of the specified predicates. * @param <V> the type of objects to be evaluated by the predicate */ + @SafeVarargs public static <V> CompoundPredicate<V> and(Predicate<? super V>... predicates) { return new AND<V>(predicates); } @@ -143,13 +144,14 @@ public final class PredicateTools { */ @SuppressWarnings("unchecked") public static <V> CompoundPredicate<V> or(Iterator<Predicate<? super V>> predicates) { - return or(IteratorTools.toArray(predicates, EMPTY_ARRAY)); + return or((Predicate<? super V>[]) IteratorTools.toArray(predicates, EMPTY_ARRAY)); } /** * Return a predicate that will OR the results of the specified predicates. * @param <V> the type of objects to be evaluated by the predicate */ + @SafeVarargs public static <V> CompoundPredicate<V> or(Predicate<? super V>... predicates) { return new OR<V>(predicates); } @@ -182,13 +184,14 @@ public final class PredicateTools { */ @SuppressWarnings("unchecked") public static <V> Predicate<V> nand(Iterator<Predicate<? super V>> predicates) { - return nand(IteratorTools.toArray(predicates, EMPTY_ARRAY)); + return nand((Predicate<? super V>[]) IteratorTools.toArray(predicates, EMPTY_ARRAY)); } /** * Return a predicate that will NAND the results of the specified predicates. * @param <V> the type of objects to be evaluated by the predicate */ + @SafeVarargs public static <V> Predicate<V> nand(Predicate<? super V>... predicates) { return not(and(predicates)); } @@ -210,13 +213,14 @@ public final class PredicateTools { */ @SuppressWarnings("unchecked") public static <V> Predicate<V> nor(Iterator<Predicate<? super V>> predicates) { - return nor(IteratorTools.toArray(predicates, EMPTY_ARRAY)); + return nor((Predicate<? super V>[]) IteratorTools.toArray(predicates, EMPTY_ARRAY)); } /** * Return a predicate that will NOR the results of the specified predicates. * @param <V> the type of objects to be evaluated by the predicate */ + @SafeVarargs public static <V> Predicate<V> nor(Predicate<? super V>... predicates) { return not(or(predicates)); } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/XOR.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/XOR.java index ef2988bae2..c4fa6a2c5e 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/XOR.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/predicate/XOR.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 Oracle. All rights reserved. + * Copyright (c) 2005, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -28,7 +28,6 @@ public class XOR<V> * Construct a predicate that will evaluate to <code>true</code> if either of * the specified predicates evaluates to <code>true</code>, but <em>not</em> both. */ - @SuppressWarnings("unchecked") public XOR(Predicate<? super V> predicate1, Predicate<? super V> predicate2) { super(predicate1, predicate2); } |