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

Last change on this file since 13717 was 13667, checked in by Don-vip, 6 years ago

move a few methods from OsmPrimitive to IPrimitive, Relation to IRelation

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4/**
5 * IRelation captures the common functions of {@link Relation} and {@link RelationData}.
6 * @since 4098
7 */
8public interface IRelation extends IPrimitive {
9
10 /**
11 * Returns the number of members.
12 * @return number of members
13 */
14 int getMembersCount();
15
16 /**
17 * Returns id of the member at given index.
18 * @param idx member index
19 * @return id of the member at given index
20 */
21 long getMemberId(int idx);
22
23 /**
24 * Returns role of the member at given index.
25 * @param idx member index
26 * @return role of the member at given index
27 */
28 String getRole(int idx);
29
30 /**
31 * Returns type of the member at given index.
32 * @param idx member index
33 * @return type of the member at given index
34 */
35 OsmPrimitiveType getMemberType(int idx);
36
37 /**
38 * Determines if at least one child primitive is incomplete.
39 *
40 * @return true if at least one child primitive is incomplete
41 * @since 13564
42 */
43 default boolean hasIncompleteMembers() {
44 return false;
45 }
46
47 @Override
48 default int compareTo(IPrimitive o) {
49 return o instanceof IRelation ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
50 }
51
52 @Override
53 default String getDisplayName(NameFormatter formatter) {
54 return formatter.format(this);
55 }
56
57 /**
58 * Determines if this relation is a boundary.
59 * @return {@code true} if a boundary relation
60 */
61 default boolean isBoundary() {
62 return "boundary".equals(get("type"));
63 }
64
65 @Override
66 default boolean isMultipolygon() {
67 return "multipolygon".equals(get("type")) || isBoundary();
68 }
69}
Note: See TracBrowser for help on using the repository browser.