diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-08-24 14:46:16 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-08-24 14:46:16 -0400 |
| commit | 90f343c701585066bf30f226811d65f3bce58c95 (patch) | |
| tree | 8b8d1f07bd2c486c9b2106f87b6c3c61f7300af2 /BJC-Utils2/src/main/java/bjc/utils/funcdata | |
| parent | 6d454caf2bfa5207957b5da775ece2a249857ddd (diff) | |
Added tentative support for subrules
Added a new sort of config reader that tentatively
supports subrules through indentation. I need to
actually write a parser that uses it though.
I think something to do with trees would work well
for testing it.
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java | 10 | ||||
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcdata/Tree.java | 3 |
2 files changed, 12 insertions, 1 deletions
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 5e0c67e..f1616b2 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/IMap.java @@ -137,4 +137,14 @@ public interface IMap<KeyType, ValueType> { * Delete all the values in the map */ void clear(); + + default ValueType getOrDefault(KeyType key, ValueType defaultValue) { + try { + return get(key); + } catch (@SuppressWarnings("unused") IllegalArgumentException iaex) { + // We don't care about this, because it indicates a key is + // missing + return defaultValue; + } + } }
\ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/Tree.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/Tree.java index 834c124..77b5673 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/Tree.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/Tree.java @@ -134,7 +134,8 @@ public class Tree<ContainedType> implements ITree<ContainedType> { Function<IList<NewType>, NewType> nodeTransformer = nodeCollapser .apply(data); - IList<NewType> collapsedChildren = children.map((child) -> { + @SuppressWarnings("unchecked") + IList<NewType> collapsedChildren = (IList<NewType>) children.map((child) -> { return child.collapse(leafTransform, nodeCollapser, (subTreeVal) -> subTreeVal); }); |
