88 */
99package de .rub .nds .modifiablevariable ;
1010
11+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerAddModification ;
12+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerExplicitValueModification ;
13+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerInteractiveModification ;
14+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerShiftLeftModification ;
15+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerShiftRightModification ;
16+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerSubtractModification ;
17+ import de .rub .nds .modifiablevariable .biginteger .BigIntegerXorModification ;
18+ import de .rub .nds .modifiablevariable .bool .BooleanExplicitValueModification ;
19+ import de .rub .nds .modifiablevariable .bool .BooleanToggleModification ;
20+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayDeleteModification ;
21+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayDuplicateModification ;
22+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayExplicitValueModification ;
23+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayInsertModification ;
24+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayPayloadModification ;
25+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayShuffleModification ;
26+ import de .rub .nds .modifiablevariable .bytearray .ByteArrayXorModification ;
27+ import de .rub .nds .modifiablevariable .integer .IntegerAddModification ;
28+ import de .rub .nds .modifiablevariable .integer .IntegerExplicitValueModification ;
29+ import de .rub .nds .modifiablevariable .integer .IntegerShiftLeftModification ;
30+ import de .rub .nds .modifiablevariable .integer .IntegerShiftRightModification ;
31+ import de .rub .nds .modifiablevariable .integer .IntegerSubtractModification ;
32+ import de .rub .nds .modifiablevariable .integer .IntegerXorModification ;
33+ import de .rub .nds .modifiablevariable .mlong .LongAddModification ;
34+ import de .rub .nds .modifiablevariable .mlong .LongExplicitValueModification ;
35+ import de .rub .nds .modifiablevariable .mlong .LongSubtractModification ;
36+ import de .rub .nds .modifiablevariable .mlong .LongXorModification ;
37+ import de .rub .nds .modifiablevariable .singlebyte .ByteAddModification ;
38+ import de .rub .nds .modifiablevariable .singlebyte .ByteExplicitValueModification ;
39+ import de .rub .nds .modifiablevariable .singlebyte .ByteSubtractModification ;
40+ import de .rub .nds .modifiablevariable .singlebyte .ByteXorModification ;
41+ import de .rub .nds .modifiablevariable .string .StringExplicitValueModification ;
42+ import de .rub .nds .modifiablevariable .util .ByteArrayAdapter ;
1143import java .io .Serializable ;
12- import javax .xml .bind .annotation .XmlAnyElement ;
13- import javax .xml .bind .annotation .XmlAttribute ;
44+ import java .util .Objects ;
45+ import javax .xml .bind .annotation .XmlAccessType ;
46+ import javax .xml .bind .annotation .XmlAccessorType ;
47+ import javax .xml .bind .annotation .XmlElement ;
48+ import javax .xml .bind .annotation .XmlElements ;
1449import javax .xml .bind .annotation .XmlRootElement ;
1550import javax .xml .bind .annotation .XmlTransient ;
51+ import javax .xml .bind .annotation .adapters .XmlJavaTypeAdapter ;
1652
1753/**
1854 * The base abstract class for modifiable variables, including the getValue
19- * function.
20- *
21- * The class needs to be defined transient to allow propOrder definition in
22- * subclasses, see:
55+ * function.The class needs to be defined transient to allow propOrder
56+ * definition in subclasses, see:
2357 * http://blog.bdoughan.com/2011/06/ignoring-inheritance-with-xmltransient.html
2458 *
59+ *
60+ * @param <E>
2561 */
2662@ XmlRootElement
2763@ XmlTransient
64+ @ XmlAccessorType (XmlAccessType .FIELD )
65+ @ XmlJavaTypeAdapter (value = ByteArrayAdapter .class , type = byte [].class )
2866public abstract class ModifiableVariable <E > implements Serializable {
2967
3068 protected Boolean autoformat = null ;
3169
70+ @ XmlElements (value = {
71+ @ XmlElement (type = BigIntegerXorModification .class , name = "BigIntegerXorModification" ),
72+ @ XmlElement (type = BigIntegerSubtractModification .class , name = "BigIntegerSubtractModification" ),
73+ @ XmlElement (type = BigIntegerShiftRightModification .class , name = "BigIntegerShiftRightModification" ),
74+ @ XmlElement (type = BigIntegerShiftLeftModification .class , name = "BigIntegerShiftLeftModification" ),
75+ @ XmlElement (type = BigIntegerExplicitValueModification .class , name = "BigIntegerExplicitValueModification" ),
76+ @ XmlElement (type = BigIntegerAddModification .class , name = "BigIntegerAddModification" ),
77+ @ XmlElement (type = BigIntegerInteractiveModification .class , name = "BigIntegerInteractiveModification" ),
78+ @ XmlElement (type = BooleanToggleModification .class , name = "BooleanToggleModification" ),
79+ @ XmlElement (type = BooleanExplicitValueModification .class , name = "BooleanExplicitValueModification" ),
80+ @ XmlElement (type = ByteArrayXorModification .class , name = "ByteArrayXorModification" ),
81+ @ XmlElement (type = ByteArrayShuffleModification .class , name = "ByteArrayShuffleModification" ),
82+ @ XmlElement (type = ByteArrayPayloadModification .class , name = "ByteArrayPayloadModification" ),
83+ @ XmlElement (type = ByteArrayInsertModification .class , name = "ByteArrayInsertModification" ),
84+ @ XmlElement (type = ByteArrayExplicitValueModification .class , name = "ByteArrayExplicitValueModification" ),
85+ @ XmlElement (type = ByteArrayDuplicateModification .class , name = "ByteArrayDuplicateModification" ),
86+ @ XmlElement (type = ByteArrayDeleteModification .class , name = "ByteArrayDeleteModification" ),
87+ @ XmlElement (type = IntegerXorModification .class , name = "IntegerXorModification" ),
88+ @ XmlElement (type = IntegerSubtractModification .class , name = "IntegerSubtractModification" ),
89+ @ XmlElement (type = IntegerShiftRightModification .class , name = "IntegerShiftRightModification" ),
90+ @ XmlElement (type = IntegerShiftLeftModification .class , name = "IntegerShiftLeftModification" ),
91+ @ XmlElement (type = IntegerExplicitValueModification .class , name = "IntegerExplicitValueModification" ),
92+ @ XmlElement (type = IntegerAddModification .class , name = "IntegerAddModification" ),
93+ @ XmlElement (type = LongXorModification .class , name = "LongXorModification" ),
94+ @ XmlElement (type = LongSubtractModification .class , name = "LongSubtractModification" ),
95+ @ XmlElement (type = LongExplicitValueModification .class , name = "LongExplicitValueModification" ),
96+ @ XmlElement (type = LongAddModification .class , name = "LongAddModification" ),
97+ @ XmlElement (type = ByteXorModification .class , name = "ByteXorModification" ),
98+ @ XmlElement (type = ByteSubtractModification .class , name = "ByteSubtractModification" ),
99+ @ XmlElement (type = ByteAddModification .class , name = "ByteAddModification" ),
100+ @ XmlElement (type = ByteExplicitValueModification .class , name = "ByteExplicitValueModification" ),
101+ @ XmlElement (type = StringExplicitValueModification .class , name = "StringExplicitValueModification" ) })
32102 private VariableModification <E > modification = null ;
33103
34- private boolean createRandomModification ;
104+ private Boolean createRandomModification ;
35105
36106 protected E assertEquals ;
37107
38108 public ModifiableVariable () {
39109
40110 }
41111
42- @ XmlAttribute (required = false )
43112 public Boolean getAutoformat () {
44113 return autoformat ;
45114 }
@@ -52,13 +121,12 @@ public void setModification(VariableModification<E> modification) {
52121 this .modification = modification ;
53122 }
54123
55- @ XmlAnyElement (lax = true )
56124 public VariableModification <E > getModification () {
57125 return modification ;
58126 }
59127
60128 public E getValue () {
61- if (createRandomModification ) {
129+ if (Objects . equals ( createRandomModification , Boolean . TRUE ) ) {
62130 createRandomModification ();
63131 createRandomModification = false ;
64132 }
@@ -87,7 +155,10 @@ public boolean containsAssertion() {
87155 return (assertEquals != null );
88156 }
89157
90- public boolean isCreateRandomModification () {
158+ public Boolean isCreateRandomModification () {
159+ if (createRandomModification == null ) {
160+ return false ;
161+ }
91162 return createRandomModification ;
92163 }
93164}
0 commit comments