Changeset 15012 in josm for trunk/src/org
- Timestamp:
- 2019-04-22T13:56:24+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r14925 r15012 18 18 import java.util.concurrent.TimeUnit; 19 19 import java.util.concurrent.atomic.AtomicLong; 20 import java.util.function.BiPredicate; 20 21 21 22 import org.openstreetmap.josm.spi.preferences.Config; … … 629 630 } 630 631 631 /** 632 * Replies the value for key <code>key</code>. Replies null, if <code>key</code> is null. 633 * Replies null, if there is no value for the given key. 634 * 635 * @param key the key. Can be null, replies null in this case. 636 * @return the value for key <code>key</code>. 637 */ 638 @Override 639 public final String get(String key) { 632 protected final String doGet(String key, BiPredicate<String, String> predicate) { 640 633 if (key == null) 641 634 return null; … … 643 636 return null; 644 637 for (int i = 0; i < keys.length; i += 2) { 645 if ( keys[i].equals(key)) return keys[i+1];638 if (predicate.test(keys[i], key)) return keys[i+1]; 646 639 } 647 640 return null; 641 } 642 643 /** 644 * Replies the value for key <code>key</code>. Replies null, if <code>key</code> is null. 645 * Replies null, if there is no value for the given key. 646 * 647 * @param key the key. Can be null, replies null in this case. 648 * @return the value for key <code>key</code>. 649 */ 650 @Override 651 public final String get(String key) { 652 return doGet(key, String::equals); 648 653 } 649 654 … … 654 659 */ 655 660 public final String getIgnoreCase(String key) { 656 if (key == null) 657 return null; 658 if (keys == null) 659 return null; 660 for (int i = 0; i < keys.length; i += 2) { 661 if (keys[i].equalsIgnoreCase(key)) return keys[i+1]; 662 } 663 return null; 661 return doGet(key, String::equalsIgnoreCase); 664 662 } 665 663
Note:
See TracChangeset
for help on using the changeset viewer.