summaryrefslogtreecommitdiff
path: root/dice/src/example/java/bjc/dicelang/neodice/statements/StatementValue.java
blob: d804a10d967d150261e98fe4150f342b847223f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package bjc.dicelang.neodice.statements;

import java.util.*;

/**
 * Represents a value for diebox, as a base class.
 * @author Ben Culkin
 *
 */
public abstract class StatementValue {
    /**
     * The type of the value.
     * @author Ben Culkin
     *
     */
	public static enum Type {
	    /** The 'void' value. There is only one value of this type. */
		VOID,
		/** The 'boolean' type. There is one true value, and one false value. */
		BOOLEAN,
		/** Represents an integer. */
		INTEGER,
		
		/** Represents a single die. */
		DIE,
		/** Represents a pool of dice. */
		DIEPOOL,
		
		/** Represents an array of some type. */
		ARRAY,
	}
	
	/** The type of this value. */
	public final Type type;
	
	/**
	 * Create a new statement value.
	 * @param type The type of the value.
	 */
	protected StatementValue(Type type) {
		this.type = type;
	}

	@Override
	public int hashCode() {
		return Objects.hash(type);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)                  return true;
		if (obj == null)                  return false;
		if (getClass() != obj.getClass()) return false;

		StatementValue other = (StatementValue) obj;
		
		return type == other.type;
	}
}