- Timestamp:
- 2016-08-18T19:23:21+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/User.java
r9371 r10841 5 5 6 6 import java.util.ArrayList; 7 import java.util.Collection; 7 8 import java.util.HashMap; 8 import java.util. HashSet;9 import java.util.LinkedHashSet; 9 10 import java.util.List; 10 11 import java.util.Map; 11 12 import java.util.Objects; 12 import java.util.Set;13 14 import org.openstreetmap.josm.tools.Utils;15 13 16 14 /** … … 135 133 136 134 /** the user name */ 137 private final Set<String> names = newHashSet<>();135 private final LinkedHashSet<String> names = new LinkedHashSet<>(); 138 136 /** the user id */ 139 137 private final long uid; … … 143 141 * 144 142 * @return the user name. Never <code>null</code>, but may be the empty string 143 * @see #getByName(String) 144 * @see #createOsmUser(long, String) 145 * @see #createLocalUser(String) 145 146 */ 146 147 public String getName() { 147 return Utils.join("/", names);148 return names.isEmpty() ? "" : names.iterator().next(); 148 149 } 149 150 … … 164 165 public void addName(String name) { 165 166 names.add(name); 167 } 168 169 /** 170 * Sets the preferred user name, i.e., the one that will be returned when calling {@link #getName()}. 171 * 172 * Rationale: A user can change its name multiple times and after reading various (outdated w.r.t. user name) 173 * data files it is unclear which is the up-to-date user name. 174 * @param name the preferred user name to set 175 */ 176 public void setPreferredName(String name) { 177 if (names.size() == 1 && names.contains(name)) { 178 return; 179 } 180 final Collection<String> allNames = new LinkedHashSet<>(names); 181 names.clear(); 182 names.add(name); 183 names.addAll(allNames); 166 184 } 167 185 -
trunk/src/org/openstreetmap/josm/io/AbstractParser.java
r8510 r10841 117 117 if (uid != null) { 118 118 user = User.createOsmUser(uid, userStr); 119 user.setPreferredName(userStr); 119 120 } else { 120 121 user = User.createLocalUser(userStr);
Note:
See TracChangeset
for help on using the changeset viewer.