-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirection.java
More file actions
57 lines (49 loc) · 1.16 KB
/
Direction.java
File metadata and controls
57 lines (49 loc) · 1.16 KB
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
package model.lightchain;
import java.io.Serializable;
/**
* Represents the semantic of direction that is used for
* traversing data structures, e.g., Merkle trees.
* A Direction can be either LEFT or RIGHT.
*/
public class Direction implements Serializable {
/**
* The value of the direction; either "Left" or "Right".
*/
private final String value;
/**
* The public static instances of Left direction.
*/
public static final Direction LEFT = new Direction("Left");
/**
* The public static instances of Right direction.
*/
public static final Direction RIGHT = new Direction("Right");
/**
* Constructor.
*
* @param value The value of the direction; either "Left" or "Right".
*/
private Direction(String value) {
this.value = value;
}
/**
* Returns true if the direction is RIGHT.
*
* @return true if the direction is RIGHT.
*/
public boolean isRight() {
return this == RIGHT;
}
/**
* Returns true if the direction is LEFT.
*
* @return true if the direction is LEFT.
*/
public boolean isLeft() {
return this == LEFT;
}
@Override
public String toString() {
return value;
}
}