Changeset 13668 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2018-04-23T22:28:34+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r13637 r13668 12 12 import java.util.Map; 13 13 import java.util.Map.Entry; 14 import java.util.Objects;15 14 import java.util.Set; 16 15 import java.util.concurrent.TimeUnit; … … 467 466 } 468 467 469 /** 470 * Calls the visitor for every key/value pair of this primitive. 471 * 472 * @param visitor The visitor to call. 473 * @see #getKeys() 474 * @since 8742 475 */ 468 @Override 476 469 public void visitKeys(KeyValueVisitor visitor) { 477 470 final String[] keys = this.keys; … … 769 762 return getName(); 770 763 } 771 772 /**773 * Tests whether this primitive contains a tag consisting of {@code key} and {@code value}.774 * @param key the key forming the tag.775 * @param value value forming the tag.776 * @return true if primitive contains a tag consisting of {@code key} and {@code value}.777 */778 public boolean hasTag(String key, String value) {779 return Objects.equals(value, get(key));780 }781 782 /**783 * Tests whether this primitive contains a tag consisting of {@code key} and any of {@code values}.784 * @param key the key forming the tag.785 * @param values one or many values forming the tag.786 * @return true if primitive contains a tag consisting of {@code key} and any of {@code values}.787 */788 public boolean hasTag(String key, String... values) {789 return hasTag(key, Arrays.asList(values));790 }791 792 /**793 * Tests whether this primitive contains a tag consisting of {@code key} and any of {@code values}.794 * @param key the key forming the tag.795 * @param values one or many values forming the tag.796 * @return true if primitive contains a tag consisting of {@code key} and any of {@code values}.797 */798 public boolean hasTag(String key, Collection<String> values) {799 return values.contains(get(key));800 }801 802 /**803 * Tests whether this primitive contains a tag consisting of {@code key} and a value different from {@code value}.804 * @param key the key forming the tag.805 * @param value value not forming the tag.806 * @return true if primitive contains a tag consisting of {@code key} and a value different from {@code value}.807 * @since 11608808 */809 public boolean hasTagDifferent(String key, String value) {810 String v = get(key);811 return v != null && !v.equals(value);812 }813 814 /**815 * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}.816 * @param key the key forming the tag.817 * @param values one or many values forming the tag.818 * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}.819 * @since 11608820 */821 public boolean hasTagDifferent(String key, String... values) {822 return hasTagDifferent(key, Arrays.asList(values));823 }824 825 /**826 * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}.827 * @param key the key forming the tag.828 * @param values one or many values forming the tag.829 * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}.830 * @since 11608831 */832 public boolean hasTagDifferent(String key, Collection<String> values) {833 String v = get(key);834 return v != null && !values.contains(v);835 }836 764 } -
trunk/src/org/openstreetmap/josm/data/osm/Tagged.java
r13625 r13668 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.Arrays; 4 5 import java.util.Collection; 5 6 import java.util.Map; 7 import java.util.Objects; 6 8 7 9 /** … … 35 37 36 38 /** 39 * Calls the visitor for every key/value pair. 40 * 41 * @param visitor The visitor to call. 42 * @see #getKeys() 43 * @since 13668 44 */ 45 default void visitKeys(KeyValueVisitor visitor) { 46 getKeys().forEach((k, v) -> visitor.visitKeyValue(this, k, v)); 47 } 48 49 /** 37 50 * Sets a key/value pairs 38 51 * … … 101 114 102 115 /** 116 * Tests whether this primitive contains a tag consisting of {@code key} and {@code value}. 117 * @param key the key forming the tag. 118 * @param value value forming the tag. 119 * @return true if primitive contains a tag consisting of {@code key} and {@code value}. 120 * @since 13668 121 */ 122 default boolean hasTag(String key, String value) { 123 return Objects.equals(value, get(key)); 124 } 125 126 /** 127 * Tests whether this primitive contains a tag consisting of {@code key} and any of {@code values}. 128 * @param key the key forming the tag. 129 * @param values one or many values forming the tag. 130 * @return true if primitive contains a tag consisting of {@code key} and any of {@code values}. 131 * @since 13668 132 */ 133 default boolean hasTag(String key, String... values) { 134 return hasTag(key, Arrays.asList(values)); 135 } 136 137 /** 138 * Tests whether this primitive contains a tag consisting of {@code key} and any of {@code values}. 139 * @param key the key forming the tag. 140 * @param values one or many values forming the tag. 141 * @return true if primitive contains a tag consisting of {@code key} and any of {@code values}. 142 * @since 13668 143 */ 144 default boolean hasTag(String key, Collection<String> values) { 145 return values.contains(get(key)); 146 } 147 148 /** 149 * Tests whether this primitive contains a tag consisting of {@code key} and a value different from {@code value}. 150 * @param key the key forming the tag. 151 * @param value value not forming the tag. 152 * @return true if primitive contains a tag consisting of {@code key} and a value different from {@code value}. 153 * @since 13668 154 */ 155 default boolean hasTagDifferent(String key, String value) { 156 String v = get(key); 157 return v != null && !v.equals(value); 158 } 159 160 /** 161 * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}. 162 * @param key the key forming the tag. 163 * @param values one or many values forming the tag. 164 * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}. 165 * @since 13668 166 */ 167 default boolean hasTagDifferent(String key, String... values) { 168 return hasTagDifferent(key, Arrays.asList(values)); 169 } 170 171 /** 172 * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}. 173 * @param key the key forming the tag. 174 * @param values one or many values forming the tag. 175 * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}. 176 * @since 13668 177 */ 178 default boolean hasTagDifferent(String key, Collection<String> values) { 179 String v = get(key); 180 return v != null && !values.contains(v); 181 } 182 183 /** 103 184 * Replies the set of keys 104 185 *
Note:
See TracChangeset
for help on using the changeset viewer.