Skip to content

Commit

Permalink
remove collections and move lowercase map to MapUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Feb 23, 2025
1 parent 1cadb2f commit 4c1c1e1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 164 deletions.
13 changes: 0 additions & 13 deletions collections/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 30 additions & 4 deletions common/src/main/java/me/hsgamer/hscore/common/MapUtils.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package me.hsgamer.hscore.common;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.function.Supplier;

/**
* Methods on Map
Expand Down Expand Up @@ -121,4 +119,32 @@ public static Optional<Map<String, Object>> castOptionalStringObjectMap(Object o
public static Optional<Map<String, Object>> castOptionalStringObjectMap(Object object) {
return castOptionalStringObjectMap(object, true);
}

/**
* Create a new map with lowercase keys
*
* @param map the map
* @param mapSupplier the map constructor
* @param <V> the value type
* @param <M> the map type
*
* @return the new map
*/
public static <V, M extends Map<String, V>> M createLowercaseStringMap(Map<String, V> map, Supplier<M> mapSupplier) {
M newMap = mapSupplier.get();
map.forEach((k, v) -> newMap.put(k.toLowerCase(Locale.ROOT), v));
return newMap;
}

/**
* Create a {@link LinkedHashMap} with lowercase keys
*
* @param map the map
* @param <V> the value type
*
* @return the new map
*/
public static <V> Map<String, V> createLowercaseStringMap(Map<String, V> map) {
return createLowercaseStringMap(map, LinkedHashMap::new);
}
}
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<module>extra</module>
<module>variable</module>
<module>builder</module>
<module>collections</module>
<module>web</module>
<module>request</module>
<module>serializer</module>
Expand Down

0 comments on commit 4c1c1e1

Please sign in to comment.