Changeset 13665 in josm


Ignore:
Timestamp:
2018-04-23T21:57:10+02:00 (20 months ago)
Author:
Don-vip
Message:

move primitive comparison logic to interfaces

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
8 edited

Legend:

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

    r13564 r13665  
    3131
    3232    @Override
     33    default int compareTo(IPrimitive o) {
     34        return o instanceof INode ? Long.compare(getUniqueId(), o.getUniqueId()) : 1;
     35    }
     36
     37    @Override
    3338    default String getDisplayName(NameFormatter formatter) {
    3439        return formatter.format(this);
  • trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java

    r13664 r13665  
    1111 * @since 4098
    1212 */
    13 public interface IPrimitive extends Tagged, PrimitiveId, Stylable {
     13public interface IPrimitive extends Tagged, PrimitiveId, Stylable, Comparable<IPrimitive> {
    1414
    1515    /**
     
    147147     * </ul>
    148148     * @return {@code true} if this object is drawable
    149      * @since xxx
     149     * @since 13664
    150150     */
    151151    default boolean isDrawable() {
     
    156156     * Determines whether the primitive is selected
    157157     * @return whether the primitive is selected
    158      * @since xxx
     158     * @since 13664
    159159     */
    160160    default boolean isSelected() {
     
    165165     * Determines if this primitive is a member of a selected relation.
    166166     * @return {@code true} if this primitive is a member of a selected relation, {@code false} otherwise
    167      * @since xxx
     167     * @since 13664
    168168     */
    169169    default boolean isMemberOfSelected() {
     
    174174     * Determines if this primitive is an outer member of a selected multipolygon relation.
    175175     * @return {@code true} if this primitive is an outer member of a selected multipolygon relation, {@code false} otherwise
    176      * @since xxx
     176     * @since 13664
    177177     */
    178178    default boolean isOuterMemberOfSelected() {
  • trunk/src/org/openstreetmap/josm/data/osm/IRelation.java

    r13564 r13665  
    4646
    4747    @Override
     48    default int compareTo(IPrimitive o) {
     49        return o instanceof IRelation ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
     50    }
     51
     52    @Override
    4853    default String getDisplayName(NameFormatter formatter) {
    4954        return formatter.format(this);
  • trunk/src/org/openstreetmap/josm/data/osm/IWay.java

    r13564 r13665  
    4444
    4545    @Override
     46    default int compareTo(IPrimitive o) {
     47        if (o instanceof IRelation)
     48            return 1;
     49        return o instanceof IWay ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
     50    }
     51
     52    @Override
    4653    default String getDisplayName(NameFormatter formatter) {
    4754        return formatter.format(this);
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r13564 r13665  
    312312
    313313    @Override
    314     public int compareTo(OsmPrimitive o) {
    315         return o instanceof Node ? Long.compare(getUniqueId(), o.getUniqueId()) : 1;
    316     }
    317 
    318     @Override
    319314    public OsmPrimitiveType getType() {
    320315        return OsmPrimitiveType.NODE;
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r13664 r13665  
    4242 * @author imi
    4343 */
    44 public abstract class OsmPrimitive extends AbstractPrimitive implements Comparable<OsmPrimitive>, TemplateEngineDataProvider {
     44public abstract class OsmPrimitive extends AbstractPrimitive implements TemplateEngineDataProvider {
    4545    private static final String SPECIAL_VALUE_ID = "id";
    4646    private static final String SPECIAL_VALUE_LOCAL_NAME = "localname";
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r13564 r13665  
    318318    }
    319319
    320     @Override
    321     public int compareTo(OsmPrimitive o) {
    322         return o instanceof Relation ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
    323     }
    324 
    325320    /**
    326321     * Returns the first member.
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r13564 r13665  
    333333        }
    334334        return true;
    335     }
    336 
    337     @Override
    338     public int compareTo(OsmPrimitive o) {
    339         if (o instanceof Relation)
    340             return 1;
    341         return o instanceof Way ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
    342335    }
    343336
Note: See TracChangeset for help on using the changeset viewer.