Changeset 10691 in josm for trunk/src/org/openstreetmap/josm/tools/Utils.java
- Timestamp:
- 2016-07-31T17:58:31+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r10689 r10691 50 50 import java.util.concurrent.ThreadFactory; 51 51 import java.util.concurrent.atomic.AtomicLong; 52 import java.util.function.Predicate; 52 53 import java.util.regex.Matcher; 53 54 import java.util.regex.Pattern; … … 106 107 * @param predicate the predicate 107 108 * @return {@code true} if {@code predicate} applies to at least one element from {@code collection} 108 * @deprecated use {@link Stream#anyMatch( java.util.function.Predicate)} instead.109 * @deprecated use {@link Stream#anyMatch(Predicate)} instead. 109 110 */ 110 111 @Deprecated 111 112 public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) { 112 113 for (T item : collection) { 113 if (predicate. evaluate(item)) {114 if (predicate.test(item)) { 114 115 return true; 115 116 } … … 125 126 * @param predicate the predicate 126 127 * @return {@code true} if {@code predicate} applies to all elements from {@code collection} 127 * @deprecated use {@link Stream#allMatch( java.util.function.Predicate)} instead.128 * @deprecated use {@link Stream#allMatch(Predicate)} instead. 128 129 */ 129 130 @Deprecated 130 131 public static <T> boolean forAll(Iterable<? extends T> collection, Predicate<? super T> predicate) { 131 return !exists(collection, Predicates.not(predicate));132 return !exists(collection, predicate.negate()); 132 133 } 133 134 … … 152 153 public static <T> T find(Iterable<? extends T> collection, Predicate<? super T> predicate) { 153 154 for (T item : collection) { 154 if (predicate. evaluate(item)) {155 if (predicate.test(item)) { 155 156 return item; 156 157 } … … 169 170 public static <T> T find(Iterable<? extends Object> collection, Class<? extends T> clazz) { 170 171 return (T) find(collection, Predicates.<Object>isInstanceOf(clazz)); 171 }172 173 /**174 * Creates a new {@link FilteredCollection}.175 * @param <T> The collection type.176 * @param collection The collection to filter.177 * @param predicate The predicate to filter for.178 * @return The new {@link FilteredCollection}179 * @deprecated Use java predicates and {@link SubclassFilteredCollection#filter(Collection, java.util.function.Predicate)} instead.180 */181 @Deprecated182 @SuppressWarnings("unused")183 public static <T> Collection<T> filter(Collection<? extends T> collection, Predicate<? super T> predicate) {184 // Diamond operator does not work with Java 9 here185 return new FilteredCollection<T>(collection, predicate);186 172 } 187 173 … … 225 211 int i = 0; 226 212 for (T item : collection) { 227 if (predicate. evaluate(item))213 if (predicate.test(item)) 228 214 return i; 229 215 i++; … … 758 744 public static String escapeReservedCharactersHTML(String s) { 759 745 return s == null ? "" : s.replace("&", "&").replace("<", "<").replace(">", ">"); 760 }761 762 /**763 * Represents a function that can be applied to objects of {@code A} and764 * returns objects of {@code B}.765 * @param <A> class of input objects766 * @param <B> class of transformed objects767 *768 * @deprecated Use java.util.function.Function instead.769 */770 @Deprecated771 @FunctionalInterface772 public interface Function<A, B> extends java.util.function.Function<A, B> {773 774 /**775 * Applies the function on {@code x}.776 * @param x an object of777 * @return the transformed object778 */779 @Override780 B apply(A x);781 746 } 782 747
Note:
See TracChangeset
for help on using the changeset viewer.