forked from liquid-java/liquidjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorEnumUsage.java
More file actions
35 lines (27 loc) · 811 Bytes
/
ErrorEnumUsage.java
File metadata and controls
35 lines (27 loc) · 811 Bytes
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
// State Refinement Error
package testSuite;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@SuppressWarnings("unused")
@StateSet({"photoMode", "videoMode", "noMode"})
class ErrorEnumUsage {
enum Mode {
Photo, Video, Unknown
}
Mode mode;
@StateRefinement(to="noMode(this)")
public ErrorEnumUsage() {}
@StateRefinement(from="noMode(this) && mode == Mode.Photo", to="photoMode(this)")
@StateRefinement(from="noMode(this) && mode == Mode.Video", to="videoMode(this)")
public void setMode(Mode mode) {
this.mode = mode;
}
@StateRefinement(from="photoMode(this)")
public void takePhoto() {}
public static void main(String[] args) {
// Correct
ErrorEnumUsage st = new ErrorEnumUsage();
st.setMode(Mode.Video);
st.takePhoto(); //error
}
}