Skip to content

Commit 70d2369

Browse files
committed
Updated ModifiableVariableVersion and added Hashcode and EqualsMethods
1 parent 9fbf66e commit 70d2369

31 files changed

+817
-33
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>de.rub.nds</groupId>
55
<artifactId>ModifiableVariable</artifactId>
6-
<version>2.4</version>
6+
<version>2.5</version>
77
<packaging>jar</packaging>
88

99
<name>ModifiableVariable</name>

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerAddModification.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
import de.rub.nds.modifiablevariable.VariableModification;
1212
import java.math.BigInteger;
13+
import java.util.Objects;
1314
import java.util.Random;
1415
import javax.xml.bind.annotation.XmlRootElement;
1516
import javax.xml.bind.annotation.XmlType;
1617

1718
@XmlRootElement
18-
@XmlType(propOrder = { "summand", "modificationFilter", "postModification" })
19+
@XmlType(propOrder = {"summand", "modificationFilter", "postModification"})
1920
public class BigIntegerAddModification extends VariableModification<BigInteger> {
2021

2122
private final static int MAX_ADD_LENGTH = 8;
@@ -47,4 +48,30 @@ public void setSummand(BigInteger summand) {
4748
public VariableModification<BigInteger> getModifiedCopy() {
4849
return new BigIntegerAddModification(summand.add(new BigInteger(MAX_ADD_LENGTH, new Random())));
4950
}
51+
52+
@Override
53+
public int hashCode() {
54+
int hash = 7;
55+
hash = 41 * hash + Objects.hashCode(this.summand);
56+
return hash;
57+
}
58+
59+
@Override
60+
public boolean equals(Object obj) {
61+
if (this == obj) {
62+
return true;
63+
}
64+
if (obj == null) {
65+
return false;
66+
}
67+
if (getClass() != obj.getClass()) {
68+
return false;
69+
}
70+
final BigIntegerAddModification other = (BigIntegerAddModification) obj;
71+
if (!Objects.equals(this.summand, other.summand)) {
72+
return false;
73+
}
74+
return true;
75+
}
76+
5077
}

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerExplicitValueModification.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
import de.rub.nds.modifiablevariable.VariableModification;
1212
import java.math.BigInteger;
13+
import java.util.Objects;
1314
import java.util.Random;
1415
import javax.xml.bind.annotation.XmlRootElement;
1516
import javax.xml.bind.annotation.XmlType;
1617

1718
@XmlRootElement
18-
@XmlType(propOrder = { "explicitValue", "modificationFilter", "postModification" })
19+
@XmlType(propOrder = {"explicitValue", "modificationFilter", "postModification"})
1920
public class BigIntegerExplicitValueModification extends VariableModification<BigInteger> {
2021

2122
private final static int MAX_EXPLICIT_LENGTH = 8;
@@ -52,4 +53,29 @@ public VariableModification<BigInteger> getModifiedCopy() {
5253
explicitValue.subtract(new BigInteger(MAX_EXPLICIT_LENGTH, r)));
5354
}
5455
}
56+
57+
@Override
58+
public int hashCode() {
59+
int hash = 3;
60+
hash = 41 * hash + Objects.hashCode(this.explicitValue);
61+
return hash;
62+
}
63+
64+
@Override
65+
public boolean equals(Object obj) {
66+
if (this == obj) {
67+
return true;
68+
}
69+
if (obj == null) {
70+
return false;
71+
}
72+
if (getClass() != obj.getClass()) {
73+
return false;
74+
}
75+
final BigIntegerExplicitValueModification other = (BigIntegerExplicitValueModification) obj;
76+
if (!Objects.equals(this.explicitValue, other.explicitValue)) {
77+
return false;
78+
}
79+
return true;
80+
}
5581
}

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerShiftLeftModification.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import javax.xml.bind.annotation.XmlType;
1616

1717
@XmlRootElement
18-
@XmlType(propOrder = { "shift", "modificationFilter", "postModification" })
18+
@XmlType(propOrder = {"shift", "modificationFilter", "postModification"})
1919
public class BigIntegerShiftLeftModification extends VariableModification<BigInteger> {
2020

2121
private final static int MAX_SHIFT_LENGTH = 32;
@@ -50,4 +50,29 @@ public void setShift(int shift) {
5050
public VariableModification<BigInteger> getModifiedCopy() {
5151
return new BigIntegerShiftLeftModification(shift + new Random().nextInt(MAX_SHIFT_LENGTH));
5252
}
53+
54+
@Override
55+
public int hashCode() {
56+
int hash = 7;
57+
hash = 97 * hash + this.shift;
58+
return hash;
59+
}
60+
61+
@Override
62+
public boolean equals(Object obj) {
63+
if (this == obj) {
64+
return true;
65+
}
66+
if (obj == null) {
67+
return false;
68+
}
69+
if (getClass() != obj.getClass()) {
70+
return false;
71+
}
72+
final BigIntegerShiftLeftModification other = (BigIntegerShiftLeftModification) obj;
73+
if (this.shift != other.shift) {
74+
return false;
75+
}
76+
return true;
77+
}
5378
}

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerShiftRightModification.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import javax.xml.bind.annotation.XmlType;
1616

1717
@XmlRootElement
18-
@XmlType(propOrder = { "shift", "modificationFilter", "postModification" })
18+
@XmlType(propOrder = {"shift", "modificationFilter", "postModification"})
1919
public class BigIntegerShiftRightModification extends VariableModification<BigInteger> {
2020

2121
private final static int MAX_SHIFT_LENGTH = 32;
@@ -50,4 +50,29 @@ public void setShift(int shift) {
5050
public VariableModification<BigInteger> getModifiedCopy() {
5151
return new BigIntegerShiftRightModification(shift + new Random().nextInt(MAX_SHIFT_LENGTH));
5252
}
53+
54+
@Override
55+
public int hashCode() {
56+
int hash = 7;
57+
hash = 97 * hash + this.shift;
58+
return hash;
59+
}
60+
61+
@Override
62+
public boolean equals(Object obj) {
63+
if (this == obj) {
64+
return true;
65+
}
66+
if (obj == null) {
67+
return false;
68+
}
69+
if (getClass() != obj.getClass()) {
70+
return false;
71+
}
72+
final BigIntegerShiftRightModification other = (BigIntegerShiftRightModification) obj;
73+
if (this.shift != other.shift) {
74+
return false;
75+
}
76+
return true;
77+
}
5378
}

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerSubtractModification.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
import de.rub.nds.modifiablevariable.VariableModification;
1212
import java.math.BigInteger;
13+
import java.util.Objects;
1314
import java.util.Random;
1415
import javax.xml.bind.annotation.XmlRootElement;
1516
import javax.xml.bind.annotation.XmlType;
1617

1718
@XmlRootElement
18-
@XmlType(propOrder = { "subtrahend", "modificationFilter", "postModification" })
19+
@XmlType(propOrder = {"subtrahend", "modificationFilter", "postModification"})
1920
public class BigIntegerSubtractModification extends VariableModification<BigInteger> {
2021

2122
private final static int MAX_SUBTRACT_LENGTH = 8;
@@ -50,4 +51,29 @@ public void setSubtrahend(BigInteger subtrahend) {
5051
public VariableModification<BigInteger> getModifiedCopy() {
5152
return new BigIntegerSubtractModification(subtrahend.add(new BigInteger(MAX_SUBTRACT_LENGTH, new Random())));
5253
}
54+
55+
@Override
56+
public int hashCode() {
57+
int hash = 5;
58+
hash = 61 * hash + Objects.hashCode(this.subtrahend);
59+
return hash;
60+
}
61+
62+
@Override
63+
public boolean equals(Object obj) {
64+
if (this == obj) {
65+
return true;
66+
}
67+
if (obj == null) {
68+
return false;
69+
}
70+
if (getClass() != obj.getClass()) {
71+
return false;
72+
}
73+
final BigIntegerSubtractModification other = (BigIntegerSubtractModification) obj;
74+
if (!Objects.equals(this.subtrahend, other.subtrahend)) {
75+
return false;
76+
}
77+
return true;
78+
}
5379
}

src/main/java/de/rub/nds/modifiablevariable/biginteger/BigIntegerXorModification.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010

1111
import de.rub.nds.modifiablevariable.VariableModification;
1212
import java.math.BigInteger;
13+
import java.util.Objects;
1314
import java.util.Random;
1415
import javax.xml.bind.annotation.XmlRootElement;
1516
import javax.xml.bind.annotation.XmlType;
1617

1718
@XmlRootElement
18-
@XmlType(propOrder = { "xor", "modificationFilter", "postModification" })
19+
@XmlType(propOrder = {"xor", "modificationFilter", "postModification"})
1920
public class BigIntegerXorModification extends VariableModification<BigInteger> {
2021

2122
private final static int MAX_XOR_LENGTH = 8;
@@ -50,4 +51,29 @@ public void setXor(BigInteger xor) {
5051
public VariableModification<BigInteger> getModifiedCopy() {
5152
return new BigIntegerXorModification(xor.add(new BigInteger(MAX_XOR_LENGTH, new Random())));
5253
}
54+
55+
@Override
56+
public int hashCode() {
57+
int hash = 7;
58+
hash = 97 * hash + Objects.hashCode(this.xor);
59+
return hash;
60+
}
61+
62+
@Override
63+
public boolean equals(Object obj) {
64+
if (this == obj) {
65+
return true;
66+
}
67+
if (obj == null) {
68+
return false;
69+
}
70+
if (getClass() != obj.getClass()) {
71+
return false;
72+
}
73+
final BigIntegerXorModification other = (BigIntegerXorModification) obj;
74+
if (!Objects.equals(this.xor, other.xor)) {
75+
return false;
76+
}
77+
return true;
78+
}
5379
}

src/main/java/de/rub/nds/modifiablevariable/bool/BooleanExplicitValueModification.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import javax.xml.bind.annotation.XmlType;
1414

1515
@XmlRootElement
16-
@XmlType(propOrder = { "explicitValue", "modificationFilter", "postModification" })
16+
@XmlType(propOrder = {"explicitValue", "modificationFilter", "postModification"})
1717
public class BooleanExplicitValueModification extends VariableModification<Boolean> {
1818

1919
private boolean explicitValue;
@@ -42,4 +42,29 @@ public void setExplicitValue(boolean explicitValue) {
4242
public VariableModification<Boolean> getModifiedCopy() {
4343
return new BooleanExplicitValueModification(!explicitValue);
4444
}
45+
46+
@Override
47+
public int hashCode() {
48+
int hash = 7;
49+
hash = 29 * hash + (this.explicitValue ? 1 : 0);
50+
return hash;
51+
}
52+
53+
@Override
54+
public boolean equals(Object obj) {
55+
if (this == obj) {
56+
return true;
57+
}
58+
if (obj == null) {
59+
return false;
60+
}
61+
if (getClass() != obj.getClass()) {
62+
return false;
63+
}
64+
final BooleanExplicitValueModification other = (BooleanExplicitValueModification) obj;
65+
if (this.explicitValue != other.explicitValue) {
66+
return false;
67+
}
68+
return true;
69+
}
4570
}

src/main/java/de/rub/nds/modifiablevariable/bool/BooleanToogleModification.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@XmlRootElement
1616
@XmlType(propOrder = { "modificationFilter", "postModification" })
1717
public class BooleanToogleModification extends VariableModification<Boolean> {
18-
18+
1919
public BooleanToogleModification() {
2020
}
2121

@@ -31,4 +31,24 @@ protected Boolean modifyImplementationHook(Boolean input) {
3131
public VariableModification<Boolean> getModifiedCopy() {
3232
return new BooleanToogleModification();
3333
}
34+
35+
@Override
36+
public int hashCode() {
37+
int hash = 7;
38+
return hash;
39+
}
40+
41+
@Override
42+
public boolean equals(Object obj) {
43+
if (this == obj) {
44+
return true;
45+
}
46+
if (obj == null) {
47+
return false;
48+
}
49+
if (getClass() != obj.getClass()) {
50+
return false;
51+
}
52+
return true;
53+
}
3454
}

src/main/java/de/rub/nds/modifiablevariable/bytearray/ByteArrayDeleteModification.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import javax.xml.bind.annotation.XmlType;
1818

1919
@XmlRootElement
20-
@XmlType(propOrder = { "count", "startPosition", "modificationFilter", "postModification" })
20+
@XmlType(propOrder = {"count", "startPosition", "modificationFilter", "postModification"})
2121
public class ByteArrayDeleteModification extends VariableModification<byte[]> {
2222

2323
private final static int MAX_MODIFIER_LENGTH = 32;
@@ -103,4 +103,33 @@ public VariableModification<byte[]> getModifiedCopy() {
103103
return new ByteArrayDeleteModification(startPosition, modifier);
104104
}
105105
}
106+
107+
@Override
108+
public int hashCode() {
109+
int hash = 7;
110+
hash = 89 * hash + this.count;
111+
hash = 89 * hash + this.startPosition;
112+
return hash;
113+
}
114+
115+
@Override
116+
public boolean equals(Object obj) {
117+
if (this == obj) {
118+
return true;
119+
}
120+
if (obj == null) {
121+
return false;
122+
}
123+
if (getClass() != obj.getClass()) {
124+
return false;
125+
}
126+
final ByteArrayDeleteModification other = (ByteArrayDeleteModification) obj;
127+
if (this.count != other.count) {
128+
return false;
129+
}
130+
if (this.startPosition != other.startPosition) {
131+
return false;
132+
}
133+
return true;
134+
}
106135
}

0 commit comments

Comments
 (0)