Changeset 10691 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2016-07-31T17:58:31+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/FilteredCollection.java
r10657 r10691 3 3 4 4 import java.util.Collection; 5 import java.util.function.Predicate; 5 6 6 7 /** … … 17 18 * @param predicate The predicate to use as filter 18 19 */ 19 public FilteredCollection(Collection<? extends T> collection, java.util.function.Predicate<? super T> predicate) {20 public FilteredCollection(Collection<? extends T> collection, Predicate<? super T> predicate) { 20 21 super(collection, predicate); 21 22 } -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r10684 r10691 16 16 import java.util.List; 17 17 import java.util.Set; 18 import java.util.function.Predicate; 18 19 19 20 import org.openstreetmap.josm.Main; … … 887 888 * @return {@code true} if the node is inside the multipolygon 888 889 */ 889 public static boolean isNodeInsideMultiPolygon(Node node, Relation multiPolygon, java.util.function.Predicate<Way> isOuterWayAMatch) {890 public static boolean isNodeInsideMultiPolygon(Node node, Relation multiPolygon, Predicate<Way> isOuterWayAMatch) { 890 891 return isPolygonInsideMultiPolygon(Collections.singletonList(node), multiPolygon, isOuterWayAMatch); 891 892 } … … 901 902 * @return {@code true} if the polygon formed by nodes is inside the multipolygon 902 903 */ 903 public static boolean isPolygonInsideMultiPolygon(List<Node> nodes, Relation multiPolygon, 904 java.util.function.Predicate<Way> isOuterWayAMatch) { 904 public static boolean isPolygonInsideMultiPolygon(List<Node> nodes, Relation multiPolygon, Predicate<Way> isOuterWayAMatch) { 905 905 // Extract outer/inner members from multipolygon 906 906 final MultiPolygonMembers mpm = new MultiPolygonMembers(multiPolygon); -
trunk/src/org/openstreetmap/josm/tools/Predicates.java
r10594 r10691 4 4 import java.util.Collection; 5 5 import java.util.Objects; 6 import java.util.function.Predicate; 6 7 import java.util.regex.Pattern; 7 8 … … 34 35 public static <T> Predicate<T> alwaysFalse() { 35 36 return o -> false; 36 }37 38 /**39 * Returns the negation of {@code predicate}.40 * @param <T> type of items41 * @param predicate the predicate to negate42 * @return the negation of {@code predicate}43 * @deprecated Use {@link java.util.function.Predicate#negate()}44 */45 @Deprecated46 public static <T> Predicate<T> not(final Predicate<T> predicate) {47 return obj -> !predicate.evaluate(obj);48 37 } 49 38 -
trunk/src/org/openstreetmap/josm/tools/SubclassFilteredCollection.java
r10657 r10691 6 6 import java.util.Iterator; 7 7 import java.util.NoSuchElementException; 8 import java.util.function.Predicate; 8 9 9 10 /** … … 22 23 23 24 private final Collection<? extends S> collection; 24 private final java.util.function.Predicate<? super S> predicate;25 private final Predicate<? super S> predicate; 25 26 private int size = -1; 26 27 … … 72 73 * @param collection The base collection to filter 73 74 * @param predicate The predicate to use as filter 74 * @ deprecated Use java predicates instead.75 * @see #filter(Collection, Predicate) for an alternative way to construct this. 75 76 */ 76 @Deprecated77 77 public SubclassFilteredCollection(Collection<? extends S> collection, Predicate<? super S> predicate) { 78 this(collection, (java.util.function.Predicate<? super S>) predicate);79 }80 81 /**82 * Constructs a new {@code SubclassFilteredCollection}.83 * @param collection The base collection to filter84 * @param predicate The predicate to use as filter85 * @see #filter(Collection, java.util.function.Predicate) for an alternative way to construct this.86 */87 public SubclassFilteredCollection(Collection<? extends S> collection, java.util.function.Predicate<? super S> predicate) {88 78 this.collection = collection; 89 79 this.predicate = predicate; … … 120 110 * @return The filtered collection. It is a {@code Collection<T>}. 121 111 */ 122 public static <T> SubclassFilteredCollection<T, T> filter(Collection<? extends T> collection, java.util.function.Predicate<T> predicate) {112 public static <T> SubclassFilteredCollection<T, T> filter(Collection<? extends T> collection, Predicate<T> predicate) { 123 113 return new SubclassFilteredCollection<>(collection, predicate); 124 114 } -
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.