Rev 1791 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1782 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
1791 | jmachado | 3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.GensonBuilder; |
||
5 | import org.json.JSONException; |
||
6 | import org.json.JSONObject; |
||
1814 | jmachado | 7 | import pt.estgp.estgweb.domain.typesgen.VariableType; |
1791 | jmachado | 8 | |
1782 | jmachado | 9 | /** |
10 | * Created by jorgemachado on 17/06/17. |
||
11 | */ |
||
1791 | jmachado | 12 | public class BpmnVariableImpl extends BpmnVariable |
13 | { |
||
14 | protected static Genson genson; |
||
15 | |||
16 | static |
||
17 | { |
||
18 | genson = new GensonBuilder() |
||
19 | .useClassMetadata(true) |
||
20 | .useFields(false) |
||
21 | .useMethods(true) |
||
22 | .useRuntimeType(true) |
||
23 | .create(); |
||
24 | } |
||
25 | public BpmnVariableImpl() { |
||
26 | } |
||
27 | |||
28 | public BpmnVariableImpl(1.5.0/docs/api/java/lang/String.html">String name, VariableType type) |
||
29 | { |
||
30 | setType(type); |
||
31 | setName(name); |
||
32 | } |
||
33 | |||
34 | public static BpmnVariableImpl fromString(1.5.0/docs/api/java/lang/String.html">String variableJson) |
||
35 | { |
||
36 | if(variableJson == null) |
||
37 | return null; |
||
38 | return genson.deserialize(variableJson,BpmnVariableImpl.class); |
||
39 | } |
||
40 | |||
41 | public JSONObject toJsonObject() throws JSONException |
||
42 | { |
||
43 | return new JSONObject(genson.serialize(this)); |
||
44 | } |
||
45 | |||
46 | public 1.5.0/docs/api/java/lang/String.html">String toJson() { |
||
47 | return genson.serialize(this); |
||
48 | } |
||
1782 | jmachado | 49 | } |