Changeset 12809 in josm


Ignore:
Timestamp:
2017-09-09T23:32:37+02:00 (15 months 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
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r12663 r12809  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.data.APIDataSet;
    20 import org.openstreetmap.josm.data.osm.Changeset;
    2120import org.openstreetmap.josm.data.osm.DataSet;
    2221import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
     
    2524import org.openstreetmap.josm.data.osm.Relation;
    2625import org.openstreetmap.josm.data.osm.Way;
    27 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     26import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    2827import org.openstreetmap.josm.gui.MainApplication;
    2928import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    183182     *
    184183     */
    185     static class UploadHullBuilder implements Visitor {
     184    static class UploadHullBuilder implements OsmPrimitiveVisitor {
    186185        private Set<OsmPrimitive> hull;
    187186
     
    225224                }
    226225            }
    227         }
    228 
    229         @Override
    230         public void visit(Changeset cs) {
    231             // do nothing
    232226        }
    233227
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r12749 r12809  
    1919import org.openstreetmap.josm.data.osm.Relation;
    2020import org.openstreetmap.josm.data.osm.Way;
    21 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     21import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    2222import org.openstreetmap.josm.gui.MainApplication;
    2323import org.openstreetmap.josm.gui.layer.Layer;
     
    4444    public static final int IS_INCOMPLETE = 2;
    4545
    46     private static final class CloneVisitor extends AbstractVisitor {
     46    private static final class CloneVisitor implements OsmPrimitiveVisitor {
    4747        public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<>();
    4848
  • 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) {
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r12161 r12809  
    1616import org.openstreetmap.josm.data.osm.Way;
    1717import org.openstreetmap.josm.data.osm.WaySegment;
    18 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     18import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1919import org.openstreetmap.josm.gui.MapView;
    2020import org.openstreetmap.josm.gui.draw.MapViewPath;
     
    2727 * @since 5671
    2828 */
    29 public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor {
     29public class PaintVisitor implements OsmPrimitiveVisitor, ValidatorVisitor {
    3030    /** The graphics */
    3131    private final Graphics2D g;
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r12718 r12809  
    2222import org.openstreetmap.josm.data.osm.Way;
    2323import org.openstreetmap.josm.data.osm.search.SearchCompiler.NotOutsideDataSourceArea;
    24 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     24import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    2525import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2626import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    3838 * @author frsantos
    3939 */
    40 public class Test extends AbstractVisitor implements Comparable<Test> {
     40public class Test implements OsmPrimitiveVisitor, Comparable<Test> {
    4141
    4242    protected static final Predicate<OsmPrimitive> IN_DOWNLOADED_AREA = new NotOutsideDataSourceArea();
  • trunk/src/org/openstreetmap/josm/data/validation/util/AggregatePrimitivesVisitor.java

    r8378 r12809  
    1010import org.openstreetmap.josm.data.osm.RelationMember;
    1111import org.openstreetmap.josm.data.osm.Way;
    12 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     12import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1313
    1414/**
     
    1919 * @author frsantos
    2020 */
    21 public class AggregatePrimitivesVisitor extends AbstractVisitor {
     21public class AggregatePrimitivesVisitor implements OsmPrimitiveVisitor {
    2222    /** Aggregated data */
    2323    private final Collection<OsmPrimitive> aggregatedData = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/data/validation/util/NameVisitor.java

    r12663 r12809  
    1111import org.openstreetmap.josm.data.osm.Relation;
    1212import org.openstreetmap.josm.data.osm.Way;
    13 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     13import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    1414import org.openstreetmap.josm.tools.ImageProvider;
    1515
     
    1919 * @author imi
    2020 */
    21 public class NameVisitor extends AbstractVisitor {
     21public class NameVisitor implements OsmPrimitiveVisitor {
    2222
    2323    /**
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r12672 r12809  
    5151import org.openstreetmap.josm.data.osm.RelationMember;
    5252import org.openstreetmap.josm.data.osm.Way;
    53 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    54 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     53import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    5554import org.openstreetmap.josm.data.preferences.ColorProperty;
    5655import org.openstreetmap.josm.gui.HelpAwareOptionPane;
     
    253252            return;
    254253        g.setColor(preferencesColor);
    255         Visitor conflictPainter = new ConflictPainter(nc, g);
     254        OsmPrimitiveVisitor conflictPainter = new ConflictPainter(nc, g);
    256255        synchronized (this) {
    257256            for (OsmPrimitive o : lstConflicts.getSelectedValuesList()) {
     
    542541     * Paints conflicts.
    543542     */
    544     public static class ConflictPainter extends AbstractVisitor {
     543    public static class ConflictPainter implements OsmPrimitiveVisitor {
    545544        // Manage a stack of visited relations to avoid infinite recursion with cyclic relations (fix #7938)
    546545        private final Set<Relation> visited = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r12743 r12809  
    3535import org.openstreetmap.josm.data.osm.history.HistoryRelation;
    3636import org.openstreetmap.josm.data.osm.history.HistoryWay;
    37 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     37import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    3838import org.openstreetmap.josm.gui.MainApplication;
    3939import org.openstreetmap.josm.gui.layer.Layer;
     
    645645     *
    646646     */
    647     static class HistoryPrimitiveBuilder extends AbstractVisitor {
     647    static class HistoryPrimitiveBuilder implements OsmPrimitiveVisitor {
    648648        private HistoryOsmPrimitive clone;
    649649
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r12718 r12809  
    7676import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
    7777import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener;
    78 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    7978import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     79import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    8080import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory;
    8181import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
     
    243243     * A listener that counts the number of primitives it encounters
    244244     */
    245     public static final class DataCountVisitor extends AbstractVisitor {
     245    public static final class DataCountVisitor implements OsmPrimitiveVisitor {
    246246        /**
    247247         * Nodes that have been visited
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r12620 r12809  
    1919import org.openstreetmap.josm.data.osm.RelationMember;
    2020import org.openstreetmap.josm.data.osm.Way;
    21 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     21import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    2222import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
    2323import org.openstreetmap.josm.gui.mappaint.Environment;
     
    143143         *
    144144         */
    145         private class MatchingReferrerFinder extends AbstractVisitor {
     145        private class MatchingReferrerFinder implements OsmPrimitiveVisitor {
    146146            private final Environment e;
    147147
     
    195195        }
    196196
    197         private abstract static class AbstractFinder extends AbstractVisitor {
     197        private abstract static class AbstractFinder implements OsmPrimitiveVisitor {
    198198            protected final Environment e;
    199199
     
    241241            }
    242242
    243             private final AbstractVisitor innerVisitor = new AbstractFinder(e) {
     243            private final OsmPrimitiveVisitor innerVisitor = new AbstractFinder(e) {
    244244                @Override
    245245                public void visit(Relation r) {
  • trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java

    r12806 r12809  
    2828import org.openstreetmap.josm.data.osm.Relation;
    2929import org.openstreetmap.josm.data.osm.Way;
    30 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
     30import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    3131import org.openstreetmap.josm.data.projection.Projection;
    3232import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    9797    }
    9898
    99     private class GeometryPrimitiveVisitor extends AbstractVisitor {
     99    private class GeometryPrimitiveVisitor implements OsmPrimitiveVisitor {
    100100
    101101        private final JsonObjectBuilder geomObj;
Note: See TracChangeset for help on using the changeset viewer.