Skip to content

Commit

Permalink
Allow null values in ObjectMap Lists
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed May 9, 2019
1 parent 0a01728 commit e3a8cbc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
@@ -0,0 +1,16 @@
package net.ME1312.Galaxi.Library.Callback;

/**
* Exception Callback
*
* @param <T> Object
*/
public interface ExceptionCallback<T> {
/**
* Callback
*
* @param obj Object
* @throws Throwable Exception
*/
void run(T obj) throws Throwable;
}
@@ -0,0 +1,18 @@
package net.ME1312.Galaxi.Library.Callback;

/**
* Exception Callback with a return parameter
*
* @param <T> Object
* @param <R> Return parameter
*/
public interface ExceptionReturnCallback<T, R> {
/**
* Callback
*
* @param obj Object
* @return Return parameter
* @throws Throwable Exception
*/
R run(T obj) throws Throwable;
}
Expand Up @@ -473,7 +473,7 @@ public List<ObjectMap<K>> getMapList(K handle, List<? extends ObjectMap<? extend
} else if (def != null) {
List<ObjectMap<K>> values = new ArrayList<ObjectMap<K>>();
for (ObjectMap<? extends K> value : def) {
values.add(new ObjectMap(value.get(), null, null));
values.add(new ObjectMap((value == null)?null:value.get(), null, null));
}
return values;
} else return null;
Expand Down
Expand Up @@ -4,10 +4,7 @@
import net.ME1312.Galaxi.Library.Version.Version;
import org.yaml.snakeyaml.Yaml;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;

/**
* Object Map Class
Expand Down Expand Up @@ -212,9 +209,9 @@ public String asRawString() {
*/
public List<String> asRawStringList() {
if (obj != null) {
List<String> values = new ArrayList<String>();
List<String> values = new LinkedList<>();
for (Object value : (List<?>) obj) {
values.add(value.toString());
values.add((value == null)?null:value.toString());
}
return values;
} else return null;
Expand All @@ -239,7 +236,7 @@ public List<String> asStringList() {
if (obj != null) {
List<String> values = new ArrayList<String>();
for (String value : asRawStringList()) {
values.add(Util.unescapeJavaString(value));
values.add((value == null)?null:Util.unescapeJavaString(value));
}
return values;
} else return null;
Expand All @@ -264,7 +261,7 @@ public List<UUID> asUUIDList() {
if (obj != null) {
List<UUID> values = new ArrayList<UUID>();
for (String value : (List<String>) obj) {
values.add(UUID.fromString(value));
values.add((value == null)?null:UUID.fromString(value));
}
return values;
} else return null;
Expand All @@ -289,7 +286,7 @@ public List<Version> asVersionList() {
if (obj != null) {
List<Version> values = new ArrayList<Version>();
for (String value : (List<String>) obj) {
values.add(Version.fromString(value));
values.add((value == null)?null:Version.fromString(value));
}
return values;
} else return null;
Expand Down

0 comments on commit e3a8cbc

Please sign in to comment.