Changeset 11394 in josm
- Timestamp:
- 2016-12-14T04:19:09+01:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/preferences/ListListSetting.java
r10235 r11394 5 5 import java.util.Collection; 6 6 import java.util.Collections; 7 import java.util.Iterator;8 7 import java.util.List; 9 10 import org.openstreetmap.josm.tools.Utils;11 8 12 9 /** … … 39 36 } 40 37 return new ListListSetting(null); 41 }42 43 @Override44 public boolean equalVal(List<List<String>> otherVal) {45 if (value == null)46 return otherVal == null;47 if (otherVal == null)48 return false;49 if (value.size() != otherVal.size())50 return false;51 Iterator<List<String>> itA = value.iterator();52 Iterator<List<String>> itB = otherVal.iterator();53 while (itA.hasNext()) {54 if (!Utils.equalCollection(itA.next(), itB.next()))55 return false;56 }57 return true;58 38 } 59 39 … … 92 72 return new ListListSetting(null); 93 73 } 94 95 @Override96 public boolean equals(Object other) {97 if (!(other instanceof ListListSetting))98 return false;99 return equalVal(((ListListSetting) other).getValue());100 }101 74 } -
trunk/src/org/openstreetmap/josm/data/preferences/ListSetting.java
r10235 r11394 6 6 import java.util.Collections; 7 7 import java.util.List; 8 9 import org.openstreetmap.josm.tools.Utils;10 8 11 9 /** … … 33 31 34 32 @Override 35 public boolean equalVal(List<String> otherVal) {36 return Utils.equalCollection(value, otherVal);37 }38 39 @Override40 33 public ListSetting copy() { 41 34 return ListSetting.create(value); … … 56 49 return new ListSetting(null); 57 50 } 58 59 @Override60 public boolean equals(Object other) {61 if (!(other instanceof ListSetting))62 return false;63 return equalVal(((ListSetting) other).getValue());64 }65 51 } -
trunk/src/org/openstreetmap/josm/data/preferences/MapListSetting.java
r10235 r11394 4 4 import java.util.ArrayList; 5 5 import java.util.Collections; 6 import java.util.Iterator;7 6 import java.util.LinkedHashMap; 8 7 import java.util.List; 9 8 import java.util.Map; 10 import java.util.Map.Entry;11 import java.util.Objects;12 9 13 10 /** … … 24 21 super(value); 25 22 consistencyTest(); 26 }27 28 @Override29 public boolean equalVal(List<Map<String, String>> otherVal) {30 if (value == null)31 return otherVal == null;32 if (otherVal == null)33 return false;34 if (value.size() != otherVal.size())35 return false;36 Iterator<Map<String, String>> itA = value.iterator();37 Iterator<Map<String, String>> itB = otherVal.iterator();38 while (itA.hasNext()) {39 if (!equalMap(itA.next(), itB.next()))40 return false;41 }42 return true;43 }44 45 private static boolean equalMap(Map<String, String> a, Map<String, String> b) {46 if (a == null)47 return b == null;48 if (b == null)49 return false;50 if (a.size() != b.size())51 return false;52 for (Entry<String, String> e : a.entrySet()) {53 if (!Objects.equals(e.getValue(), b.get(e.getKey())))54 return false;55 }56 return true;57 23 } 58 24 … … 91 57 return new MapListSetting(null); 92 58 } 93 94 @Override95 public boolean equals(Object other) {96 if (!(other instanceof MapListSetting))97 return false;98 return equalVal(((MapListSetting) other).getValue());99 }100 59 } -
trunk/src/org/openstreetmap/josm/data/preferences/Setting.java
r9821 r11394 25 25 * @return true if the values are equal 26 26 */ 27 boolean equalVal(T otherVal); 27 default boolean equalVal(T otherVal) { 28 return getValue() == null ? (otherVal == null) : getValue().equals(otherVal); 29 } 28 30 29 31 /** -
trunk/src/org/openstreetmap/josm/data/preferences/StringSetting.java
r9759 r11394 16 16 17 17 @Override 18 public boolean equalVal(String otherVal) {19 if (value == null)20 return otherVal == null;21 return value.equals(otherVal);22 }23 24 @Override25 18 public StringSetting copy() { 26 19 return new StringSetting(value); … … 36 29 return new StringSetting(null); 37 30 } 38 39 @Override40 public boolean equals(Object other) {41 if (!(other instanceof StringSetting))42 return false;43 return equalVal(((StringSetting) other).getValue());44 }45 31 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r11374 r11394 42 42 import java.util.List; 43 43 import java.util.Locale; 44 import java.util.Objects;45 44 import java.util.concurrent.Executor; 46 45 import java.util.concurrent.ForkJoinPool; … … 524 523 public static boolean equalsEpsilon(double a, double b) { 525 524 return Math.abs(a - b) <= EPSILON; 526 }527 528 /**529 * Determines if two collections are equal.530 * @param a first collection531 * @param b second collection532 * @return {@code true} if collections are equal, {@code false} otherwise533 * @since 9217534 */535 public static boolean equalCollection(Collection<?> a, Collection<?> b) {536 if (a == null) return b == null;537 if (b == null) return false;538 if (a.size() != b.size()) return false;539 Iterator<?> itA = a.iterator();540 Iterator<?> itB = b.iterator();541 while (itA.hasNext()) {542 if (!Objects.equals(itA.next(), itB.next()))543 return false;544 }545 return true;546 525 } 547 526
Note:
See TracChangeset
for help on using the changeset viewer.