source: josm/trunk/src/org/openstreetmap/josm/data/osm/IRelation.java@ 13908

Last change on this file since 13908 was 13908, checked in by Don-vip, 7 years ago

add IRelation.setMembers()

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.List;
5
6/**
7 * IRelation captures the common functions of {@link Relation} and {@link RelationData}.
8 * @param <M> Type of OSM relation member
9 * @since 4098
10 */
11public interface IRelation<M extends IRelationMember<?>> extends IPrimitive {
12
13 /**
14 * Returns the number of members.
15 * @return number of members
16 */
17 int getMembersCount();
18
19 /**
20 * Returns the relation member at the specified index.
21 * @param index the index of the relation member
22 * @return relation member at the specified index
23 * @since 13766 (IRelation)
24 */
25 M getMember(int index);
26
27 /**
28 * Returns members of the relation.
29 * @return Members of the relation. Changes made in returned list are not mapped
30 * back to the primitive, use {@link #setMembers} to modify the members
31 * @since 1925
32 * @since 13766 (IRelation)
33 */
34 List<M> getMembers();
35
36 /**
37 * Sets members of the relation.
38 * @param members Can be null, in that case all members are removed
39 */
40 void setMembers(List<M> members);
41
42 /**
43 * Returns id of the member at given index.
44 * @param idx member index
45 * @return id of the member at given index
46 */
47 long getMemberId(int idx);
48
49 /**
50 * Returns role of the member at given index.
51 * @param idx member index
52 * @return role of the member at given index
53 */
54 String getRole(int idx);
55
56 /**
57 * Returns type of the member at given index.
58 * @param idx member index
59 * @return type of the member at given index
60 */
61 OsmPrimitiveType getMemberType(int idx);
62
63 /**
64 * Determines if at least one child primitive is incomplete.
65 *
66 * @return true if at least one child primitive is incomplete
67 * @since 13564
68 */
69 default boolean hasIncompleteMembers() {
70 return false;
71 }
72
73 @Override
74 default int compareTo(IPrimitive o) {
75 return o instanceof IRelation ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
76 }
77
78 @Override
79 default String getDisplayName(NameFormatter formatter) {
80 return formatter.format(this);
81 }
82
83 /**
84 * Determines if this relation is a boundary.
85 * @return {@code true} if a boundary relation
86 */
87 default boolean isBoundary() {
88 return "boundary".equals(get("type"));
89 }
90
91 @Override
92 default boolean isMultipolygon() {
93 return "multipolygon".equals(get("type")) || isBoundary();
94 }
95}
Note: See TracBrowser for help on using the repository browser.