summaryrefslogtreecommitdiff
path: root/RGens/src/main/java/bjc/rgens/newparser/Rule.java
diff options
context:
space:
mode:
Diffstat (limited to 'RGens/src/main/java/bjc/rgens/newparser/Rule.java')
-rw-r--r--RGens/src/main/java/bjc/rgens/newparser/Rule.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/RGens/src/main/java/bjc/rgens/newparser/Rule.java b/RGens/src/main/java/bjc/rgens/newparser/Rule.java
index 0197860..aee1a89 100644
--- a/RGens/src/main/java/bjc/rgens/newparser/Rule.java
+++ b/RGens/src/main/java/bjc/rgens/newparser/Rule.java
@@ -7,7 +7,7 @@ import java.util.Random;
/**
* A rule in a randomized grammar.
- *
+ *
* @author EVE
*
*/
@@ -21,17 +21,17 @@ public class Rule {
/**
* Create a new grammar rule.
- *
+ *
* @param ruleName
* The name of the grammar rule.
- *
+ *
* @throws IllegalArgumentException
* If the rule name is invalid.
*/
public Rule(String ruleName) {
- if(ruleName == null) {
+ if (ruleName == null) {
throw new NullPointerException("Rule name must not be null");
- } else if(ruleName.equals("")) {
+ } else if (ruleName.equals("")) {
throw new IllegalArgumentException("The empty string is not a valid rule name");
}
@@ -42,12 +42,12 @@ public class Rule {
/**
* Adds a case to the rule.
- *
+ *
* @param cse
* The case to add.
*/
public void addCase(RuleCase cse) {
- if(cse == null) {
+ if (cse == null) {
throw new NullPointerException("Case must not be null");
}
@@ -56,7 +56,7 @@ public class Rule {
/**
* Get a random case from this rule.
- *
+ *
* @return A random case from this rule.
*/
public RuleCase getCase() {
@@ -65,10 +65,10 @@ public class Rule {
/**
* Get a random case from this rule.
- *
+ *
* @param rnd
* The random number generator to use.
- *
+ *
* @return A random case from this rule.
*/
public RuleCase getCase(Random rnd) {
@@ -77,7 +77,7 @@ public class Rule {
/**
* Get all the cases of this rule.
- *
+ *
* @return All the cases in this rule.
*/
public IList<RuleCase> getCases() {
@@ -97,19 +97,21 @@ public class Rule {
@Override
public boolean equals(Object obj) {
- if(this == obj) return true;
- if(obj == null) return false;
- if(!(obj instanceof Rule)) return false;
+ if (this == obj) return true;
+
+ if (obj == null) return false;
+
+ if (!(obj instanceof Rule)) return false;
Rule other = (Rule) obj;
- if(cases == null) {
- if(other.cases != null) return false;
- } else if(!cases.equals(other.cases)) return false;
+ if (cases == null) {
+ if (other.cases != null) return false;
+ } else if (!cases.equals(other.cases)) return false;
- if(name == null) {
- if(other.name != null) return false;
- } else if(!name.equals(other.name)) return false;
+ if (name == null) {
+ if (other.name != null) return false;
+ } else if (!name.equals(other.name)) return false;
return true;
}