-
Notifications
You must be signed in to change notification settings - Fork 1
/
modelEnum.mustache
50 lines (42 loc) · 1.06 KB
/
modelEnum.mustache
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
import java.io.IOException;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
/**
* Gets or Sets
*/
@JsonAdapter(.Adapter.class)
public enum {
_UNSUPPORTED_ENUM("_UNSUPPORTED_ENUM");
private value;
( value) {
this.value = value;
}
public getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static fromValue( value) {
for ( b : .values()) {
if (b.value.equals(value)) {
return b;
}
}
return ._UNSUPPORTED_ENUM;
}
public static class Adapter extends TypeAdapter<> {
@Override
public void write(final JsonWriter jsonWriter, final enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public read(final JsonReader jsonReader) throws IOException {
value = jsonReader.next();
return .fromValue(value);
}
}
}