Changeset 18207 in josm for trunk/src/org/openstreetmap/josm/tools/Utils.java
- Timestamp:
- 2021-09-11T17:00:13+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r18072 r18207 650 650 public static <T> List<T> toUnmodifiableList(Collection<T> collection) { 651 651 // Java 9: use List.of(...) 652 if ( collection == null || collection.isEmpty()) {652 if (isEmpty(collection)) { 653 653 return Collections.emptyList(); 654 654 } else if (collection.size() == 1) { … … 672 672 @SuppressWarnings("unchecked") 673 673 public static <K, V> Map<K, V> toUnmodifiableMap(Map<K, V> map) { 674 if ( map == null || map.isEmpty()) {674 if (isEmpty(map)) { 675 675 return Collections.emptyMap(); 676 676 } else if (map.size() == 1) { … … 689 689 690 690 /** 691 * Determines if a collection is null or empty. 692 * @param collection collection 693 * @return {@code true} if collection is null or empty 694 * @since 18207 695 */ 696 public static boolean isEmpty(Collection<?> collection) { 697 return collection == null || collection.isEmpty(); 698 } 699 700 /** 701 * Determines if a map is null or empty. 702 * @param map map 703 * @return {@code true} if map is null or empty 704 * @since 18207 705 */ 706 public static boolean isEmpty(Map<?, ?> map) { 707 return map == null || map.isEmpty(); 708 } 709 710 /** 711 * Determines if a string is null or empty. 712 * @param string string 713 * @return {@code true} if string is null or empty 714 * @since 18207 715 */ 716 public static boolean isEmpty(String string) { 717 return string == null || string.isEmpty(); 718 } 719 720 /** 691 721 * Returns the first not empty string in the given candidates, otherwise the default string. 692 722 * @param defaultString default string returned if all candidates would be empty if stripped … … 737 767 */ 738 768 public static String strip(final String str, final String skipChars) { 739 if ( str == null || str.isEmpty()) {769 if (isEmpty(str)) { 740 770 return str; 741 771 } … … 774 804 */ 775 805 public static String removeWhiteSpaces(String s) { 776 if ( s == null || s.isEmpty()) {806 if (isEmpty(s)) { 777 807 return s; 778 808 }
Note:
See TracChangeset
for help on using the changeset viewer.