From 27cae6bcf184f7e27822886f5a7320f771913b71 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Tue, 18 Dec 2018 15:12:44 +0200 Subject: [PATCH] Add hashCode and equals to AbstractExpressionCompilationRequest gitlab #239 Change-Id: I33940420ee95a52d14042bd6857be4950d878dbb --- .../AbstractExpressionCompilationRequest.java | 5 +++ .../scl/CompileResourceValueRequest.java | 26 +++++++++++++ .../db/layer0/scl/CompileValueRequest.java | 32 ++++++++++++++++ ...mpileProceduralExpressionValueRequest.java | 38 +++++++++++++++++++ 4 files changed, 101 insertions(+) diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/AbstractExpressionCompilationRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/AbstractExpressionCompilationRequest.java index 3a95f2530..28b10c896 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/AbstractExpressionCompilationRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/AbstractExpressionCompilationRequest.java @@ -236,4 +236,9 @@ implements Read> { return graph.getPossibleRelatedValue(predicate, L0.RequiresValueType, Bindings.STRING); } + @Override + public abstract int hashCode(); + + @Override + public abstract boolean equals(Object obj); } diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileResourceValueRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileResourceValueRequest.java index e56c3d5ce..cdc787d26 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileResourceValueRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileResourceValueRequest.java @@ -110,4 +110,30 @@ public class CompileResourceValueRequest extends AbstractExpressionCompilationRe return null; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((literal == null) ? 0 : literal.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; + CompileResourceValueRequest other = (CompileResourceValueRequest) obj; + if (literal == null) { + if (other.literal != null) + return false; + } else if (!literal.equals(other.literal)) + return false; + return true; + } + + } diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileValueRequest.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileValueRequest.java index 11f3ad185..e0ed90a89 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileValueRequest.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/scl/CompileValueRequest.java @@ -129,4 +129,36 @@ public class CompileValueRequest extends AbstractExpressionCompilationRequest