summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java b/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java
index 5d054cf..4153e7d 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gen/RandomGrammar.java
@@ -5,7 +5,7 @@ import bjc.utils.funcdata.IList;
/**
* A weighted grammar where all the rules have a equal chance of occuring.
- *
+ *
* @author ben
*
* @param <E>
@@ -21,7 +21,7 @@ public class RandomGrammar<E> extends WeightedGrammar<E> {
/**
* Add cases to a specified rule.
- *
+ *
* @param rule
* The name of the rule to add cases to.
* @param cases
@@ -29,14 +29,14 @@ public class RandomGrammar<E> extends WeightedGrammar<E> {
*/
@SafeVarargs
public final void addCases(E rule, IList<E>... cases) {
- for (IList<E> currentCase : cases) {
+ for(IList<E> currentCase : cases) {
super.addCase(rule, 1, currentCase);
}
}
/**
* Create a rule with the specified name and cases.
- *
+ *
* @param rule
* The name of the rule to add.
* @param cases
@@ -46,23 +46,21 @@ public class RandomGrammar<E> extends WeightedGrammar<E> {
public final void makeRule(E rule, IList<E>... cases) {
super.addRule(rule);
- for (IList<E> currentCase : cases) {
+ for(IList<E> currentCase : cases) {
super.addCase(rule, 1, currentCase);
}
}
/**
* Create a rule with the specified name and cases.
- *
+ *
* @param rule
* The name of the rule to add.
* @param cases
* The cases to add for this rule.
*/
public void makeRule(E rule, IList<IList<E>> cases) {
- if (cases == null) {
- throw new NullPointerException("Cases must not be null");
- }
+ if(cases == null) throw new NullPointerException("Cases must not be null");
super.addRule(rule);