[New] Updated implementations of equals()/hashCode() for state variables
This commit is contained in:
parent
0ccb3aaa83
commit
0cd54539bf
|
@ -16,6 +16,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
|
@ -86,38 +87,23 @@ public class BooleanValue implements IValue<Boolean>, Serializable {
|
||||||
return new BooleanValue(this.value);
|
return new BooleanValue(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
BooleanValue other = (BooleanValue) obj;
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IValue<Boolean> o) {
|
public int compareTo(IValue<Boolean> o) {
|
||||||
return Boolean.compare(this.value, o.getValue());
|
return Boolean.compare(this.value, o.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
BooleanValue that = (BooleanValue) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,36 +123,6 @@ public class FloatListValue implements IValue<List<Double>>, Serializable {
|
||||||
return new FloatListValue(this.value);
|
return new FloatListValue(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FloatListValue other = (FloatListValue) obj;
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IValue<List<Double>> o) {
|
public int compareTo(IValue<List<Double>> o) {
|
||||||
List<Double> otherValues = o.getValue();
|
List<Double> otherValues = o.getValue();
|
||||||
|
@ -160,4 +130,19 @@ public class FloatListValue implements IValue<List<Double>>, Serializable {
|
||||||
return 0;
|
return 0;
|
||||||
return Integer.compare(this.value.size(), otherValues.size());
|
return Integer.compare(this.value.size(), otherValues.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
FloatListValue that = (FloatListValue) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
|
@ -95,38 +96,23 @@ public class FloatValue implements IValue<Double>, Serializable {
|
||||||
return new FloatValue(this.value);
|
return new FloatValue(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FloatValue other = (FloatValue) obj;
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IValue<Double> o) {
|
public int compareTo(IValue<Double> o) {
|
||||||
return Double.compare(this.value, o.getValue());
|
return Double.compare(this.value, o.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
FloatValue that = (FloatValue) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,7 @@ package li.strolch.model.timevalue.impl;
|
||||||
import static li.strolch.model.parameter.ListParameter.VALUE_SEPARATOR2;
|
import static li.strolch.model.parameter.ListParameter.VALUE_SEPARATOR2;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
|
@ -126,36 +123,6 @@ public class IntegerListValue implements IValue<List<Integer>>, Serializable {
|
||||||
return new IntegerListValue(this.value);
|
return new IntegerListValue(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
IntegerListValue other = (IntegerListValue) obj;
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IValue<List<Integer>> o) {
|
public int compareTo(IValue<List<Integer>> o) {
|
||||||
List<Integer> otherValues = o.getValue();
|
List<Integer> otherValues = o.getValue();
|
||||||
|
@ -163,4 +130,19 @@ public class IntegerListValue implements IValue<List<Integer>>, Serializable {
|
||||||
return 0;
|
return 0;
|
||||||
return Integer.compare(this.value.size(), otherValues.size());
|
return Integer.compare(this.value.size(), otherValues.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
IntegerListValue that = (IntegerListValue) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
|
@ -86,38 +87,23 @@ public class IntegerValue implements IValue<Integer>, Serializable {
|
||||||
return new IntegerValue(this.value);
|
return new IntegerValue(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
IntegerValue other = (IntegerValue) obj;
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IValue<Integer> o) {
|
public int compareTo(IValue<Integer> o) {
|
||||||
return Integer.compare(this.value, o.getValue());
|
return Integer.compare(this.value, o.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
IntegerValue that = (IntegerValue) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
|
@ -86,38 +87,23 @@ public class LongValue implements IValue<Long>, Serializable {
|
||||||
return new LongValue(this.value);
|
return new LongValue(this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LongValue other = (LongValue) obj;
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(IValue<Long> o) {
|
public int compareTo(IValue<Long> o) {
|
||||||
return Long.compare(this.value, o.getValue());
|
return Long.compare(this.value, o.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
LongValue longValue = (LongValue) o;
|
||||||
|
return Objects.equals(value, longValue.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.model.StrolchValueType;
|
import li.strolch.model.StrolchValueType;
|
||||||
|
@ -149,4 +146,19 @@ public class StringSetValue implements IValue<Set<AString>>, Serializable {
|
||||||
return 0;
|
return 0;
|
||||||
return Integer.compare(this.aStrings.size(), otherValues.size());
|
return Integer.compare(this.aStrings.size(), otherValues.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
StringSetValue that = (StringSetValue) o;
|
||||||
|
return Objects.equals(aStrings, that.aStrings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(aStrings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package li.strolch.model.timevalue.impl;
|
package li.strolch.model.timevalue.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import li.strolch.model.timevalue.ITimeValue;
|
import li.strolch.model.timevalue.ITimeValue;
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
|
@ -89,37 +90,17 @@ public class TimeValue<T extends IValue> implements ITimeValue<T>, Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
final int prime = 31;
|
if (this == o)
|
||||||
int result = 1;
|
return true;
|
||||||
result = prime * result + Long.hashCode(this.time);
|
if (o == null || getClass() != o.getClass())
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
return false;
|
||||||
return result;
|
TimeValue<?> timeValue = (TimeValue<?>) o;
|
||||||
|
return time == timeValue.time && Objects.equals(value, timeValue.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public int hashCode() {
|
||||||
if (this == obj) {
|
return Objects.hash(time, value);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
TimeValue<T> other = (TimeValue<T>) obj;
|
|
||||||
if (this.time != other.time) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package li.strolch.model.timevalue.impl;
|
||||||
import static li.strolch.utils.helper.StringHelper.trimOrEmpty;
|
import static li.strolch.utils.helper.StringHelper.trimOrEmpty;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import li.strolch.model.timevalue.IValue;
|
import li.strolch.model.timevalue.IValue;
|
||||||
import li.strolch.model.timevalue.IValueChange;
|
import li.strolch.model.timevalue.IValueChange;
|
||||||
|
@ -86,41 +87,18 @@ public class ValueChange<T extends IValue> implements IValueChange<T>, Serializa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object o) {
|
||||||
if (this == obj) {
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
}
|
if (o == null || getClass() != o.getClass())
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
ValueChange<?> that = (ValueChange<?>) o;
|
||||||
if (getClass() != obj.getClass()) {
|
return Objects.equals(time, that.time) && Objects.equals(value, that.value);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ValueChange<?> other = (ValueChange<?>) obj;
|
|
||||||
if (this.time == null) {
|
|
||||||
if (other.time != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.time.equals(other.time)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.value == null) {
|
|
||||||
if (other.value != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!this.value.equals(other.value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hash(time, value);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((this.time == null) ? 0 : this.time.hashCode());
|
|
||||||
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
|
|
Loading…
Reference in New Issue