Ignore:
Timestamp:
2016-08-03T15:01:43+02:00 (9 years ago)
Author:
simon04
Message:

see #11390, see #12890 - Deprecate Predicates class

Location:
trunk/src/org/openstreetmap/josm/data
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java

    r10657 r10715  
    1212import java.util.Set;
    1313import java.util.concurrent.CopyOnWriteArrayList;
    14 import java.util.function.Predicate;
    1514
    1615import org.openstreetmap.josm.data.osm.Node;
     
    4342    private final CopyOnWriteArrayList<IConflictListener> listeners;
    4443
    45     private static class FilterPredicate implements Predicate<Conflict<? extends OsmPrimitive>> {
    46 
    47         private final Class<? extends OsmPrimitive> c;
    48 
    49         FilterPredicate(Class<? extends OsmPrimitive> c) {
    50             this.c = c;
    51         }
    52 
    53         @Override
    54         public boolean test(Conflict<? extends OsmPrimitive> conflict) {
    55             return conflict != null && c.isInstance(conflict.getMy());
    56         }
    57     }
    58 
    59     private static final FilterPredicate NODE_FILTER_PREDICATE = new FilterPredicate(Node.class);
    60     private static final FilterPredicate WAY_FILTER_PREDICATE = new FilterPredicate(Way.class);
    61     private static final FilterPredicate RELATION_FILTER_PREDICATE = new FilterPredicate(Relation.class);
    62 
    6344    /**
    6445     * Constructs a new {@code ConflictCollection}.
     
    364345     */
    365346    public final Collection<Conflict<? extends OsmPrimitive>> getNodeConflicts() {
    366         return SubclassFilteredCollection.filter(conflicts, NODE_FILTER_PREDICATE);
     347        return SubclassFilteredCollection.filter(conflicts, c -> c != null && c.getMy() instanceof Node);
    367348    }
    368349
     
    373354     */
    374355    public final Collection<Conflict<? extends OsmPrimitive>> getWayConflicts() {
    375         return SubclassFilteredCollection.filter(conflicts, WAY_FILTER_PREDICATE);
     356        return SubclassFilteredCollection.filter(conflicts, c -> c != null && c.getMy() instanceof Way);
    376357    }
    377358
     
    382363     */
    383364    public final Collection<Conflict<? extends OsmPrimitive>> getRelationConflicts() {
    384         return SubclassFilteredCollection.filter(conflicts, RELATION_FILTER_PREDICATE);
     365        return SubclassFilteredCollection.filter(conflicts, c -> c != null && c.getMy() instanceof Relation);
    385366    }
    386367
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r10691 r10715  
    4848import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
    4949import org.openstreetmap.josm.tools.FilteredCollection;
    50 import org.openstreetmap.josm.tools.Predicates;
    5150import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    5251import org.openstreetmap.josm.tools.Utils;
     
    458457     */
    459458    public Collection<OsmPrimitive> allPrimitives() {
    460         return getPrimitives(Predicates.alwaysTrue());
     459        return getPrimitives(o -> true);
    461460    }
    462461
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r10660 r10715  
    2828import org.openstreetmap.josm.gui.mappaint.StyleCache;
    2929import org.openstreetmap.josm.tools.CheckParameterUtil;
    30 import org.openstreetmap.josm.tools.Predicates;
    3130import org.openstreetmap.josm.tools.Utils;
    3231import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
     
    234233     * A predicate filtering nodes.
    235234     */
    236     public static final Predicate<OsmPrimitive> nodePredicate = Predicates.<OsmPrimitive>isOfClass(Node.class);
     235    public static final Predicate<OsmPrimitive> nodePredicate = Node.class::isInstance;
    237236
    238237    /**
    239238     * A predicate filtering ways.
    240239     */
    241     public static final Predicate<OsmPrimitive> wayPredicate = Predicates.<OsmPrimitive>isOfClass(Way.class);
     240    public static final Predicate<OsmPrimitive> wayPredicate = Way.class::isInstance;
    242241
    243242    /**
    244243     * A predicate filtering relations.
    245244     */
    246     public static final Predicate<OsmPrimitive> relationPredicate = Predicates.<OsmPrimitive>isOfClass(Relation.class);
     245    public static final Predicate<OsmPrimitive> relationPredicate = Relation.class::isInstance;
    247246
    248247    /**
  • trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java

    r10680 r10715  
    1919import org.openstreetmap.josm.data.validation.TestError;
    2020import org.openstreetmap.josm.tools.LanguageInfo;
    21 import org.openstreetmap.josm.tools.Predicates;
    2221import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2322
     
    166165        final List<TestError> errors = new ArrayList<>();
    167166        for (final String key : SubclassFilteredCollection.filter(p.keySet(),
    168                 Predicates.stringMatchesPattern(Pattern.compile(".*:conditional(:.*)?$")))) {
     167                Pattern.compile(":conditional(:.*)?$").asPredicate())) {
    169168            if (!isKeyValid(key)) {
    170169                errors.add(new TestError(this, Severity.WARNING, tr("Wrong syntax in {0} key", key), 3201, p));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r10657 r10715  
    2828import org.openstreetmap.josm.tools.MultiMap;
    2929import org.openstreetmap.josm.tools.Pair;
    30 import org.openstreetmap.josm.tools.Predicates;
    3130
    3231/**
     
    156155                boolean ignore = false;
    157156                for (String ignoredKey : IGNORED_KEYS.get()) {
    158                     if (error.getPrimitives().stream().anyMatch(Predicates.hasKey(ignoredKey))) {
     157                    if (error.getPrimitives().stream().anyMatch(p -> p.hasKey(ignoredKey))) {
    159158                        ignore = true;
    160159                        break;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java

    r10657 r10715  
    1515import org.openstreetmap.josm.data.validation.TestError;
    1616import org.openstreetmap.josm.gui.mappaint.ElemStyles;
    17 import org.openstreetmap.josm.tools.Predicates;
    1817
    1918/**
     
    6766        if (wayNode.isOutsideDownloadArea()) {
    6867            return;
    69         } else if (wayNode.getReferrers().stream().anyMatch(Predicates.hasTag("route", "ferry"))) {
     68        } else if (wayNode.getReferrers().stream().anyMatch(p1 -> p1.hasTag("route", "ferry"))) {
    7069            return;
    7170        } else if (isArea(p)) {
Note: See TracChangeset for help on using the changeset viewer.