|
|
@ -46,6 +46,11 @@ public class CollectionUtils { |
|
|
|
throw new UnsupportedOperationException("Construct CollectionUtils"); |
|
|
|
throw new UnsupportedOperationException("Construct CollectionUtils"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The load factor used when none specified in constructor. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static final float DEFAULT_LOAD_FACTOR = 0.75f; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a new {@link Collection} containing <i>a</i> minus a subset of |
|
|
|
* Returns a new {@link Collection} containing <i>a</i> minus a subset of |
|
|
|
* <i>b</i>. Only the elements of <i>b</i> that satisfy the predicate |
|
|
|
* <i>b</i>. Only the elements of <i>b</i> that satisfy the predicate |
|
|
@ -95,6 +100,7 @@ public class CollectionUtils { |
|
|
|
* @return string to map |
|
|
|
* @return string to map |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static Map<String, String> stringToMap(String str, String separator, String keyPrefix) { |
|
|
|
public static Map<String, String> stringToMap(String str, String separator, String keyPrefix) { |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> emptyMap = new HashMap<>(0); |
|
|
|
Map<String, String> emptyMap = new HashMap<>(0); |
|
|
|
if (StringUtils.isEmpty(str)) { |
|
|
|
if (StringUtils.isEmpty(str)) { |
|
|
|
return emptyMap; |
|
|
|
return emptyMap; |
|
|
@ -103,7 +109,8 @@ public class CollectionUtils { |
|
|
|
return emptyMap; |
|
|
|
return emptyMap; |
|
|
|
} |
|
|
|
} |
|
|
|
String[] strings = str.split(separator); |
|
|
|
String[] strings = str.split(separator); |
|
|
|
Map<String, String> map = new HashMap<>(strings.length); |
|
|
|
int initialCapacity = (int)(strings.length / DEFAULT_LOAD_FACTOR) + 1; |
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<>(initialCapacity); |
|
|
|
for (int i = 0; i < strings.length; i++) { |
|
|
|
for (int i = 0; i < strings.length; i++) { |
|
|
|
String[] strArray = strings[i].split("="); |
|
|
|
String[] strArray = strings[i].split("="); |
|
|
|
if (strArray.length != 2) { |
|
|
|
if (strArray.length != 2) { |
|
|
|