Changeset 13677 in josm


Ignore:
Timestamp:
2018-04-25T00:53:02+02:00 (7 years ago)
Author:
Don-vip
Message:

introduce IRelationMember

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
1 added
2 edited

Legend:

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

    r11747 r13677  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import java.util.Arrays;
    54import java.util.Objects;
    65import java.util.Optional;
     
    98
    109/**
    11  * A linkage class that can be used by an relation to keep a list of
    12  * members. Since membership may be qualified by a "role", a simple
    13  * list is not sufficient.
    14  *
     10 * A linkage class that can be used by an relation to keep a list of members.
     11 * Since membership may be qualified by a "role", a simple list is not sufficient.
     12 * @since 343
    1513 */
    16 public class RelationMember implements PrimitiveId {
     14public class RelationMember implements IRelationMember {
    1715
    1816    /**
     
    2624    private final OsmPrimitive member;
    2725
    28     /**
    29      * Returns the role of this relation member.
    30      * @return Role name or "". Never returns null
    31      * @since 1930
    32      */
     26    @Override
    3327    public String getRole() {
    3428        return role;
    3529    }
    3630
    37     /**
    38      * Determines if this relation member has a role.
    39      * @return True if role is set
    40      * @since 1930
    41      */
    42     public boolean hasRole() {
    43         return !"".equals(role);
    44     }
    45 
    46     /**
    47      * Determines if this relation member's role is in the given list.
    48      * @param roles The roles to look after
    49      * @return True if role is in the given list
    50      * @since 6305
    51      */
    52     public boolean hasRole(String... roles) {
    53         return Arrays.asList(roles).contains(role);
    54     }
    55 
    56     /**
    57      * Determines if this relation member is a relation.
    58      * @return True if member is relation
    59      * @since 1937
    60      */
     31    @Override
    6132    public boolean isRelation() {
    6233        return member instanceof Relation;
    6334    }
    6435
    65     /**
    66      * Determines if this relation member is a way.
    67      * @return True if member is way
    68      * @since 1937
    69      */
     36    @Override
    7037    public boolean isWay() {
    7138        return member instanceof Way;
     
    7340
    7441    /**
    75      *
     42     * Returns type of member for icon display.
    7643     * @return type of member for icon display
    7744     * @since 3844
     
    8148    }
    8249
    83     /**
    84      * Determines if this relation member is a node.
    85      * @return True if member is node
    86      * @since 1937
    87      */
     50    @Override
    8851    public boolean isNode() {
    8952        return member instanceof Node;
     
    186149
    187150    /**
    188      * PrimitiveId implementation. Returns the same value as getMemberType().getUniqueId()
     151     * PrimitiveId implementation. Returns the same value as getMember().getUniqueId()
    189152     */
    190153    @Override
     
    193156    }
    194157
     158    /**
     159     * PrimitiveId implementation. Returns the same value as getMember().isNew()
     160     */
    195161    @Override
    196162    public boolean isNew() {
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java

    r12866 r13677  
    99/**
    1010 * This is the data (role, type and id) that is stored in the database for a given relation member.
     11 * @since 2284
    1112 */
    12 public class RelationMemberData implements PrimitiveId, Serializable {
     13public class RelationMemberData implements IRelationMember, Serializable {
    1314
    1415    private static final long serialVersionUID = 381392198209333319L;
     
    4950    }
    5051
    51     /**
    52      * Get member role.
    53      * @return member role
    54      */
     52    @Override
    5553    public String getRole() {
    5654        return role;
     
    6563    }
    6664
    67     /**
    68      * Determines if this member has a role.
    69      * @return {@code true} if this member has a role
    70      */
    71     public boolean hasRole() {
    72         return !"".equals(role);
     65    @Override
     66    public boolean isNode() {
     67        return OsmPrimitiveType.NODE == memberType;
     68    }
     69
     70    @Override
     71    public boolean isWay() {
     72        return OsmPrimitiveType.WAY == memberType;
     73    }
     74
     75    @Override
     76    public boolean isRelation() {
     77        return OsmPrimitiveType.RELATION == memberType;
    7378    }
    7479
Note: See TracChangeset for help on using the changeset viewer.