1 package net.sf.jack4j;
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 public enum JackTransportState {
30 STOPPED {
31
32 @Override
33 protected int nativeIntValue() {
34 return JackConstants.JackTransportStopped();
35 }
36 },
37 ROLLING {
38
39 @Override
40 protected int nativeIntValue() {
41 return JackConstants.JackTransportRolling();
42 }
43 },
44 LOOPING {
45
46 @Override
47 protected int nativeIntValue() {
48 return JackConstants.JackTransportLooping();
49 }
50 },
51 STARTING {
52
53 @Override
54 protected int nativeIntValue() {
55 return JackConstants.JackTransportStarting();
56 }
57 },
58 ;
59
60 private Integer cachedIntValue = null;
61
62 protected abstract int nativeIntValue();
63
64
65
66
67
68 public int intValue() {
69 if (cachedIntValue == null) {
70 cachedIntValue = nativeIntValue();
71 }
72 return cachedIntValue;
73 }
74
75
76
77
78 public static JackTransportState byIntValue(int intValue) {
79 for (JackTransportState state : values()) {
80 if (state.intValue() == intValue) {
81 return state;
82 }
83 }
84 throw new IllegalArgumentException();
85 }
86 }