Skip to content

Commit

Permalink
Allow null values in MapUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Sep 28, 2024
1 parent f5c2ec4 commit 37c3353
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/java/xyz/srnyx/javautilities/MapUtility.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.srnyx.javautilities;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -42,7 +43,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull List<T> keys, @NotNull List<G> val
* @param <G> the type of the value
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
return map;
Expand All @@ -62,7 +63,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value) {
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand All @@ -85,7 +86,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand All @@ -111,7 +112,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down Expand Up @@ -140,7 +141,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4, @NotNull T key5, @NotNull G value5) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4, @NotNull T key5, @Nullable G value5) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down Expand Up @@ -172,7 +173,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4, @NotNull T key5, @NotNull G value5, @NotNull T key6, @NotNull G value6) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4, @NotNull T key5, @Nullable G value5, @NotNull T key6, @Nullable G value6) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down Expand Up @@ -207,7 +208,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4, @NotNull T key5, @NotNull G value5, @NotNull T key6, @NotNull G value6, @NotNull T key7, @NotNull G value7) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4, @NotNull T key5, @Nullable G value5, @NotNull T key6, @Nullable G value6, @NotNull T key7, @Nullable G value7) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down Expand Up @@ -245,7 +246,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4, @NotNull T key5, @NotNull G value5, @NotNull T key6, @NotNull G value6, @NotNull T key7, @NotNull G value7, @NotNull T key8, @NotNull G value8) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4, @NotNull T key5, @Nullable G value5, @NotNull T key6, @Nullable G value6, @NotNull T key7, @Nullable G value7, @NotNull T key8, @Nullable G value8) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down Expand Up @@ -286,7 +287,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4, @NotNull T key5, @NotNull G value5, @NotNull T key6, @NotNull G value6, @NotNull T key7, @NotNull G value7, @NotNull T key8, @NotNull G value8, @NotNull T key9, @NotNull G value9) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4, @NotNull T key5, @Nullable G value5, @NotNull T key6, @Nullable G value6, @NotNull T key7, @Nullable G value7, @NotNull T key8, @Nullable G value8, @NotNull T key9, @Nullable G value9) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down Expand Up @@ -330,7 +331,7 @@ public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull
* @param <G> the type of the values
*/
@NotNull
public static <T, G> Map<T, G> mapOf(@NotNull T key, @NotNull G value, @NotNull T key2, @NotNull G value2, @NotNull T key3, @NotNull G value3, @NotNull T key4, @NotNull G value4, @NotNull T key5, @NotNull G value5, @NotNull T key6, @NotNull G value6, @NotNull T key7, @NotNull G value7, @NotNull T key8, @NotNull G value8, @NotNull T key9, @NotNull G value9, @NotNull T key10, @NotNull G value10) {
public static <T, G> Map<T, G> mapOf(@NotNull T key, @Nullable G value, @NotNull T key2, @Nullable G value2, @NotNull T key3, @Nullable G value3, @NotNull T key4, @Nullable G value4, @NotNull T key5, @Nullable G value5, @NotNull T key6, @Nullable G value6, @NotNull T key7, @Nullable G value7, @NotNull T key8, @Nullable G value8, @NotNull T key9, @Nullable G value9, @NotNull T key10, @Nullable G value10) {
final Map<T, G> map = new HashMap<>();
map.put(key, value);
map.put(key2, value2);
Expand Down

0 comments on commit 37c3353

Please sign in to comment.