Ignore:
Timestamp:
2017-09-09T23:32:37+02:00 (2 years ago)
Author:
bastiK
Message:

replace abstract class AbstractVisitor by interface OsmPrimitiveVisitor; deprecate Visitor

  • data.osm.visitor.Visitor awkwardly mixes OsmPrimitive types and Changeset class; this may have been used in the past, but is no longer needed; AbstractVisitor should have been a super-interface of Visitor in the first place
  • hopefully, this is binary compatible and plugins can be updated gracefully
Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
12 edited

Legend:

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

    r12495 r12809  
    1414import org.openstreetmap.josm.data.Bounds;
    1515import org.openstreetmap.josm.data.coor.LatLon;
    16 import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1716import org.openstreetmap.josm.tools.CheckParameterUtil;
    1817import org.openstreetmap.josm.tools.date.DateUtils;
     
    108107     * Visitor pattern.
    109108     * @param v visitor
    110      */
    111     public void visit(Visitor v) {
     109     * @deprecated no longer supported
     110     */
     111    @Deprecated
     112    public void visit(org.openstreetmap.josm.data.osm.visitor.Visitor v) {
    112113        v.visit(this);
    113114    }
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r12778 r12809  
    1313import org.openstreetmap.josm.data.coor.EastNorth;
    1414import org.openstreetmap.josm.data.coor.LatLon;
     15import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1516import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    16 import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1717import org.openstreetmap.josm.data.projection.Projecting;
    1818import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    235235
    236236    @Override
    237     public void accept(Visitor visitor) {
     237    @Deprecated
     238    public void accept(org.openstreetmap.josm.data.osm.visitor.Visitor visitor) {
     239        visitor.visit(this);
     240    }
     241
     242    @Override
     243    public void accept(OsmPrimitiveVisitor visitor) {
    238244        visitor.visit(this);
    239245    }
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r12656 r12809  
    2424import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    2525import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
    26 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     26import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    2727import org.openstreetmap.josm.gui.mappaint.StyleCache;
    2828import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    10271027     *
    10281028     * @param visitor the visitor. Ignored, if null.
    1029      */
    1030     public void visitReferrers(Visitor visitor) {
     1029     * @deprecated use {@link #visitReferrers(OsmPrimitiveVisitor)}
     1030     */
     1031    @Deprecated
     1032    public void visitReferrers(org.openstreetmap.josm.data.osm.visitor.Visitor visitor) {
     1033        visitReferrers((OsmPrimitiveVisitor) visitor);
     1034    }
     1035
     1036    /**
     1037     * <p>Visits {@code visitor} for all referrers.</p>
     1038     *
     1039     * @param visitor the visitor. Ignored, if null.
     1040     * @since 12809
     1041     */
     1042    public void visitReferrers(OsmPrimitiveVisitor visitor) {
    10311043        if (visitor == null) return;
    10321044        if (this.referrers == null)
     
    10781090     * visitor function.
    10791091     * @param visitor The visitor from which the visit() function must be called.
    1080      */
    1081     public abstract void accept(Visitor visitor);
     1092     * @deprecated will be removed along with {@link Visitor}
     1093     */
     1094    @Deprecated
     1095    public abstract void accept(org.openstreetmap.josm.data.osm.visitor.Visitor visitor);
     1096
     1097    /**
     1098     * Implementation of the visitor scheme. Subclasses have to call the correct
     1099     * visitor function.
     1100     * @param visitor The visitor from which the visit() function must be called.
     1101     * @since 12809
     1102     */
     1103    public abstract void accept(OsmPrimitiveVisitor visitor);
    10821104
    10831105    /**
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r11553 r12809  
    1414
    1515import org.openstreetmap.josm.Main;
     16import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1617import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    17 import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1818import org.openstreetmap.josm.tools.CopyList;
    1919import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     
    177177
    178178    @Override
    179     public void accept(Visitor visitor) {
     179    @Deprecated
     180    public void accept(org.openstreetmap.josm.data.osm.visitor.Visitor visitor) {
     181        visitor.visit(this);
     182    }
     183
     184    @Override
     185    public void accept(OsmPrimitiveVisitor visitor) {
    180186        visitor.visit(this);
    181187    }
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r12663 r12809  
    1313import org.openstreetmap.josm.Main;
    1414import org.openstreetmap.josm.data.coor.LatLon;
     15import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1516import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    16 import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1717import org.openstreetmap.josm.tools.CopyList;
    1818import org.openstreetmap.josm.tools.Pair;
     
    207207    }
    208208
    209     @Override public void accept(Visitor visitor) {
     209    @Deprecated
     210    @Override public void accept(org.openstreetmap.josm.data.osm.visitor.Visitor visitor) {
     211        visitor.visit(this);
     212    }
     213
     214    @Override public void accept(OsmPrimitiveVisitor visitor) {
    210215        visitor.visit(this);
    211216    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/AbstractVisitor.java

    r6084 r12809  
    1010 *
    1111 * @author fred
     12 * @deprecated use {@link OsmPrimitiveVisitor}
    1213 */
     14@Deprecated
    1315public abstract class AbstractVisitor implements Visitor {
    1416
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java

    r8513 r12809  
    1616 * @author imi
    1717 */
    18 public class AllNodesVisitor extends AbstractVisitor {
     18public class AllNodesVisitor implements OsmPrimitiveVisitor {
    1919
    2020    /**
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r12725 r12809  
    2323 * @author imi
    2424 */
    25 public class BoundingXYVisitor extends AbstractVisitor {
     25public class BoundingXYVisitor implements OsmPrimitiveVisitor {
    2626
    2727    private ProjectionBounds bounds;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java

    r11461 r12809  
    3030 * @since 1891
    3131 */
    32 public class MergeSourceBuildingVisitor extends AbstractVisitor {
     32public class MergeSourceBuildingVisitor implements OsmPrimitiveVisitor {
    3333    private final DataSet selectionBase;
    3434    private final DataSet hull;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/Visitor.java

    r9059 r12809  
    33
    44import org.openstreetmap.josm.data.osm.Changeset;
    5 import org.openstreetmap.josm.data.osm.Node;
    6 import org.openstreetmap.josm.data.osm.Relation;
    7 import org.openstreetmap.josm.data.osm.Way;
    85
    96/**
     
    118 * can be visited by several different visitors.
    129 * @since 8
     10 * @deprecated class will be removed (use {@link OsmPrimitiveVisitor} if suitable)
    1311 */
    14 public interface Visitor {
    15     /**
    16      * Visiting call for points.
    17      * @param n The node to inspect.
    18      */
    19     void visit(Node n);
    20 
    21     /**
    22      * Visiting call for lines.
    23      * @param w The way to inspect.
    24      * @since 64
    25      */
    26     void visit(Way w);
    27 
    28     /**
    29      * Visiting call for relations.
    30      * @param r The relation to inspect.
    31      * @since 343
    32      */
    33     void visit(Relation r);
    34 
     12@Deprecated
     13public interface Visitor extends OsmPrimitiveVisitor {
    3514    /**
    3615     * Visiting call for changesets.
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java

    r11971 r12809  
    1414import org.openstreetmap.josm.data.osm.Relation;
    1515import org.openstreetmap.josm.data.osm.Way;
    16 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     16import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1717import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord;
    1818import org.openstreetmap.josm.gui.NavigatableComponent;
     
    3333 * @since 11914 (extracted from StyledMapRenderer)
    3434 */
    35 public class ComputeStyleListWorker extends RecursiveTask<List<StyleRecord>> implements Visitor {
     35public class ComputeStyleListWorker extends RecursiveTask<List<StyleRecord>> implements OsmPrimitiveVisitor {
    3636    private final transient List<? extends OsmPrimitive> input;
    3737    private final transient List<StyleRecord> output;
     
    128128    }
    129129
    130     @Override
    131     public void visit(Changeset cs) {
    132         throw new UnsupportedOperationException();
    133     }
    134 
    135130    /**
    136131     * Add new style records for the given node.
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    r12131 r12809  
    1919import org.openstreetmap.josm.data.Bounds;
    2020import org.openstreetmap.josm.data.osm.BBox;
    21 import org.openstreetmap.josm.data.osm.Changeset;
    2221import org.openstreetmap.josm.data.osm.DataSet;
    2322import org.openstreetmap.josm.data.osm.Node;
     
    2726import org.openstreetmap.josm.data.osm.Way;
    2827import org.openstreetmap.josm.data.osm.WaySegment;
    29 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     28import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    3029import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
    3130import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle;
     
    3938 * @since 23
    4039 */
    41 public class WireframeMapRenderer extends AbstractMapRenderer implements Visitor {
     40public class WireframeMapRenderer extends AbstractMapRenderer implements OsmPrimitiveVisitor {
    4241
    4342    /** Color Preference for ways not matching any other group */
     
    388387    }
    389388
    390     /**
    391      * Visitor for changesets not used in this class
    392      * @param cs The changeset for inspection.
    393      */
    394     @Override
    395     public void visit(Changeset cs) {/* ignore */}
    396 
    397389    @Override
    398390    public void drawNode(Node n, Color color, int size, boolean fill) {
Note: See TracChangeset for help on using the changeset viewer.