diff options
Diffstat (limited to 'base/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/base/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java b/base/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java index 0fe998d..e89ba08 100644 --- a/base/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java +++ b/base/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java @@ -47,8 +47,8 @@ public class DelimiterGroup<T> { /* * The token that opened the group, and any opening parameters. */ - private final T opener; - private final T[] params; + private final T opener; + private final T[] params; /** * Create a new instance of a delimiter group. @@ -148,8 +148,8 @@ public class DelimiterGroup<T> { final ITree<T> res = new Tree<>(chars.contents); /* - * Add either the contents of the current group, - * or subgroups if they're there. + * Add either the contents of the current group, or + * subgroups if they're there. */ if(contents.isEmpty()) { currentGroup.forEach(res::addChild); @@ -261,14 +261,12 @@ public class DelimiterGroup<T> { * open one. */ public IPair<T, T[]> doesOpen(final T marker) { - if (openDelimiters.containsKey(marker)) - return new Pair<>(openDelimiters.get(marker), null); + if(openDelimiters.containsKey(marker)) return new Pair<>(openDelimiters.get(marker), null); for(final Function<T, IPair<T, T[]>> pred : predOpeners) { final IPair<T, T[]> par = pred.apply(marker); - if (par.getLeft() != null) - return par; + if(par.getLeft() != null) return par; } return new Pair<>(null, null); @@ -329,20 +327,19 @@ public class DelimiterGroup<T> { * The name of the delimiter group */ public DelimiterGroup(final T name) { - if (name == null) - throw new NullPointerException("Group name must not be null"); + if(name == null) throw new NullPointerException("Group name must not be null"); groupName = name; - openDelimiters = new HashMap<>(); + openDelimiters = new HashMap<>(); nestedOpenDelimiters = new HashMap<>(); closingDelimiters = new HashSet<>(); topLevelExclusions = new HashSet<>(); - groupExclusions = new HashSet<>(); + groupExclusions = new HashSet<>(); - subgroups = new HashMap<>(); + subgroups = new HashMap<>(); impliedSubgroups = new HashMap<>(); predOpeners = new LinkedList<>(); @@ -359,10 +356,10 @@ public class DelimiterGroup<T> { public final void addClosing(final T... closers) { final List<T> closerList = Arrays.asList(closers); - for (final T closer : closerList) { - if (closer == null) { + for(final T closer : closerList) { + if(closer == null) { throw new NullPointerException("Closing delimiter must not be null"); - } else if (closer.equals("")) { + } else if(closer.equals("")) { /* * We can do this because equals works on * arbitrary objects, not just those of the same @@ -384,10 +381,10 @@ public class DelimiterGroup<T> { */ @SafeVarargs public final void addTopLevelForbid(final T... exclusions) { - for (final T exclusion : exclusions) { - if (exclusion == null) { + for(final T exclusion : exclusions) { + if(exclusion == null) { throw new NullPointerException("Exclusion must not be null"); - } else if (exclusion.equals("")) { + } else if(exclusion.equals("")) { /* * We can do this because equals works on * arbitrary objects, not just those of the same @@ -408,10 +405,10 @@ public class DelimiterGroup<T> { */ @SafeVarargs public final void addGroupForbid(final T... exclusions) { - for (final T exclusion : exclusions) { - if (exclusion == null) { + for(final T exclusion : exclusions) { + if(exclusion == null) { throw new NullPointerException("Exclusion must not be null"); - } else if (exclusion.equals("")) { + } else if(exclusion.equals("")) { /* * We can do this because equals works on * arbitrary objects, not just those of the same @@ -434,8 +431,7 @@ public class DelimiterGroup<T> { * The priority of this sub-group. */ public void addSubgroup(final T subgroup, final int priority) { - if (subgroup == null) - throw new NullPointerException("Subgroup marker must not be null"); + if(subgroup == null) throw new NullPointerException("Subgroup marker must not be null"); subgroups.put(subgroup, priority); } @@ -450,10 +446,9 @@ public class DelimiterGroup<T> { * The group opened by the marker. */ public void addOpener(final T opener, final T group) { - if (opener == null) + if(opener == null) throw new NullPointerException("Opener must not be null"); - else if (group == null) - throw new NullPointerException("Group to open must not be null"); + else if(group == null) throw new NullPointerException("Group to open must not be null"); openDelimiters.put(opener, group); } @@ -468,9 +463,9 @@ public class DelimiterGroup<T> { * The group opened by the marker. */ public void addNestedOpener(final T opener, final T group) { - if (opener == null) { + if(opener == null) { throw new NullPointerException("Opener must not be null"); - } else if (group == null) { + } else if(group == null) { throw new NullPointerException("Group to open must not be null"); } @@ -487,13 +482,13 @@ public class DelimiterGroup<T> { * The subgroup to imply. */ public void implySubgroup(final T closer, final T subgroup) { - if (closer == null) { + if(closer == null) { throw new NullPointerException("Closer must not be null"); - } else if (subgroup == null) { + } else if(subgroup == null) { throw new NullPointerException("Subgroup must not be null"); - } else if (!closingDelimiters.contains(closer)) { + } else if(!closingDelimiters.contains(closer)) { throw new IllegalArgumentException(String.format("No closing delimiter '%s' defined", closer)); - } else if (!subgroups.containsKey(subgroup)) { + } else if(!subgroups.containsKey(subgroup)) { throw new IllegalArgumentException(String.format("No subgroup '%s' defined", subgroup)); } |
