Changeset 13561 in josm for trunk


Ignore:
Timestamp:
2018-03-25T04:44:43+02:00 (7 years ago)
Author:
Don-vip
Message:

extract KeyValueVisitor from AbstractPrimitive, support Tagged objects

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r13309 r13561  
    2626*/
    2727public abstract class AbstractPrimitive implements IPrimitive {
    28 
    29     /**
    30      * This is a visitor that can be used to loop over the keys/values of this primitive.
    31      *
    32      * @author Michael Zangl
    33      * @since 8742
    34      * @since 10600 (functional interface)
    35      */
    36     @FunctionalInterface
    37     public interface KeyValueVisitor {
    38 
    39         /**
    40          * This method gets called for every tag received.
    41          *
    42          * @param primitive This primitive
    43          * @param key   The key
    44          * @param value The value
    45          */
    46         void visitKeyValue(AbstractPrimitive primitive, String key, String value);
    47     }
    4828
    4929    private static final AtomicLong idCounter = new AtomicLong(0);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java

    r11383 r13561  
    88
    99import org.openstreetmap.josm.command.Command;
    10 import org.openstreetmap.josm.data.osm.AbstractPrimitive;
     10import org.openstreetmap.josm.data.osm.KeyValueVisitor;
    1111import org.openstreetmap.josm.data.osm.Node;
    1212import org.openstreetmap.josm.data.osm.OsmPrimitive;
     13import org.openstreetmap.josm.data.osm.Tagged;
    1314import org.openstreetmap.josm.data.validation.Severity;
    1415import org.openstreetmap.josm.data.validation.Test;
     
    2021 * @author frsantos
    2122 */
    22 public class UntaggedNode extends Test implements AbstractPrimitive.KeyValueVisitor {
     23public class UntaggedNode extends Test implements KeyValueVisitor {
    2324
    2425    protected static final int UNTAGGED_NODE_BLANK = 201;
     
    5455    }
    5556
    56     private static OsmPrimitive[] castPrim(AbstractPrimitive n) {
     57    private static OsmPrimitive[] castPrim(Tagged n) {
    5758        return n instanceof OsmPrimitive ? (new OsmPrimitive[]{(OsmPrimitive) n}) : (new OsmPrimitive[0]);
    5859    }
    5960
    6061    @Override
    61     public void visitKeyValue(AbstractPrimitive n, String key, String value) {
     62    public void visitKeyValue(Tagged n, String key, String value) {
    6263        if (key.toLowerCase(Locale.ENGLISH).contains("fixme") || value.toLowerCase(Locale.ENGLISH).contains("fixme")) {
    6364            /* translation note: don't translate quoted words */
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r13507 r13561  
    3030
    3131import org.openstreetmap.josm.data.Version;
    32 import org.openstreetmap.josm.data.osm.AbstractPrimitive;
    33 import org.openstreetmap.josm.data.osm.AbstractPrimitive.KeyValueVisitor;
     32import org.openstreetmap.josm.data.osm.KeyValueVisitor;
    3433import org.openstreetmap.josm.data.osm.Node;
    3534import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3635import org.openstreetmap.josm.data.osm.Relation;
     36import org.openstreetmap.josm.data.osm.Tagged;
    3737import org.openstreetmap.josm.data.osm.Way;
    3838import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
     
    197197
    198198            @Override
    199             public void visitKeyValue(AbstractPrimitive p, String key, String value) {
     199            public void visitKeyValue(Tagged p, String key, String value) {
    200200                MapCSSKeyRules v = index.get(key);
    201201                if (v != null) {
Note: See TracChangeset for help on using the changeset viewer.