valueEquals implemented for AS1/2

This commit is contained in:
Jindra Petřík
2021-03-08 09:32:15 +01:00
parent 89ea68923c
commit f77d3948df
69 changed files with 1389 additions and 5 deletions

View File

@@ -645,4 +645,32 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
public boolean isIdentical(GraphTargetItem other) {
return this == other;
}
public static boolean objectsValueEquals(Object o1, Object o2) {
if (o1 == null && o2 == null) {
return true;
}
if (o1 == null || o2 == null) {
return false;
}
if ((o1 instanceof GraphTargetItem) && (o2 instanceof GraphTargetItem)) {
GraphTargetItem gt1 = (GraphTargetItem) o1;
GraphTargetItem gt2 = (GraphTargetItem) o2;
return gt1.valueEquals(gt2);
}
if ((o1 instanceof List) && (o2 instanceof List)) {
List l1 = (List) o1;
List l2 = (List) o2;
if (l1.size() != l2.size()) {
return false;
}
for (int i = 0; i < l1.size(); i++) {
if (!objectsValueEquals(l1.get(i), l2.get(i))) {
return false;
}
}
}
return o1.equals(o2);
}
}

View File

@@ -168,6 +168,24 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp {
return (Objects.equals(operator, other.operator));
}
@Override
public boolean valueEquals(GraphTargetItem obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BinaryOpItem other = (BinaryOpItem) obj;
if (!GraphTargetItem.objectsValueEquals(leftSide, other.leftSide)) {
return false;
}
if (!GraphTargetItem.objectsValueEquals(rightSide, other.rightSide)) {
return false;
}
return GraphTargetItem.objectsValueEquals(operator, other.operator);
}
/*@Override
public boolean toBoolean() {
double val=toNumber();

View File

@@ -123,6 +123,24 @@ public abstract class UnaryOpItem extends GraphTargetItem implements UnaryOp {
return true;
}
@Override
public boolean valueEquals(GraphTargetItem obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final GraphTargetItem other = (GraphTargetItem) obj;
if (!GraphTargetItem.objectsValueEquals(this.value, other.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 3;