summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/funcdata
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java8
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java11
2 files changed, 19 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
index 014c298..037b2b6 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IList.java
@@ -28,6 +28,14 @@ public interface IList<ContainedType> {
*/
boolean add(ContainedType item);
+ /**
+ * Add all of the elements in the provided list to this list
+ *
+ * @param items
+ * The list of items to add
+ * @return True if every item was succesfully added to the list, false
+ * otherwise
+ */
default boolean addAll(IList<ContainedType> items) {
return items.map(this::add).anyMatch((bl) -> bl == false);
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java
index 8522058..e69495a 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java
@@ -73,6 +73,17 @@ public interface IMap<KeyType, ValueType> {
*/
ValueType get(KeyType key);
+ /**
+ * Get a value from the map, and return a default value if the key
+ * doesn't exist
+ *
+ * @param key
+ * The key to attempt to retrieve
+ * @param defaultValue
+ * The value to return if the key doesn't exist
+ * @return The value associated with the key, or the default value if
+ * the key doesn't exist
+ */
default ValueType getOrDefault(KeyType key, ValueType defaultValue) {
try {
return get(key);