Repository: cloudslang/cloud-slang
Issue: Entity references in logs

some entities still appear as obj refs (e.g. `io.cloudslang.lang.entities.ResultNavigation@5b7d`) instead of toString representation


Changed files:
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/InOutParam.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/AsyncLoopStatement.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/MapForLoopStatement.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ListForLoopStatement.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/CompilationArtifact.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/Input.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/LoopStatement.java
cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ResultNavigation.java

diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/AsyncLoopStatement.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/AsyncLoopStatement.java
index 97972aa9f..2cebc6016 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/AsyncLoopStatement.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/AsyncLoopStatement.java
@@ -12,6 +12,7 @@ package io.cloudslang.lang.entities;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.io.Serializable;
 
@@ -43,26 +44,33 @@ public class AsyncLoopStatement extends LoopStatement implements Serializable {
         return varName;
     }
 
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .appendSuper(super.toString())
+                .append("varName", varName)
+                .toString();
+    }
+
     @Override
     public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
+        if (this == o) return true;
+
+        if (o == null || getClass() != o.getClass()) return false;
 
         AsyncLoopStatement that = (AsyncLoopStatement) o;
 
         return new EqualsBuilder()
+                .appendSuper(super.equals(o))
                 .append(varName, that.varName)
-                .append(getExpression(), that.getExpression())
                 .isEquals();
     }
 
     @Override
     public int hashCode() {
-        return new HashCodeBuilder()
+        return new HashCodeBuilder(17, 37)
+                .appendSuper(super.hashCode())
                 .append(varName)
-                .append(getExpression())
                 .toHashCode();
     }
 
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/CompilationArtifact.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/CompilationArtifact.java
index fb1b9791e..aaf92430a 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/CompilationArtifact.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/CompilationArtifact.java
@@ -8,10 +8,11 @@
  */
 package io.cloudslang.lang.entities;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import io.cloudslang.lang.entities.bindings.Input;
 import io.cloudslang.score.api.ExecutionPlan;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.util.Collection;
 import java.util.List;
@@ -50,14 +51,39 @@ public class CompilationArtifact {
         return systemProperties;
     }
 
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .append("executionPlan", executionPlan)
+                .append("dependencies", dependencies)
+                .append("inputs", inputs)
+                .append("systemProperties", systemProperties)
+                .toString();
+    }
+
     @Override
     public boolean equals(Object o) {
-        return EqualsBuilder.reflectionEquals(this, o);
+        if (this == o) return true;
+
+        if (o == null || getClass() != o.getClass()) return false;
+
+        CompilationArtifact that = (CompilationArtifact) o;
+
+        return new EqualsBuilder()
+                .append(executionPlan, that.executionPlan)
+                .append(dependencies, that.dependencies)
+                .append(inputs, that.inputs)
+                .append(systemProperties, that.systemProperties)
+                .isEquals();
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        return new HashCodeBuilder(17, 37)
+                .append(executionPlan)
+                .append(dependencies)
+                .append(inputs)
+                .append(systemProperties)
+                .toHashCode();
     }
-
 }
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ListForLoopStatement.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ListForLoopStatement.java
index 49c723b56..57229ff07 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ListForLoopStatement.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ListForLoopStatement.java
@@ -12,6 +12,7 @@ package io.cloudslang.lang.entities;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.io.Serializable;
 
@@ -45,26 +46,33 @@ public class ListForLoopStatement extends LoopStatement implements Serializable
         return varName;
     }
 
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .appendSuper(super.toString())
+                .append("varName", varName)
+                .toString();
+    }
+
     @Override
     public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
+        if (this == o) return true;
+
+        if (o == null || getClass() != o.getClass()) return false;
 
         ListForLoopStatement that = (ListForLoopStatement) o;
 
         return new EqualsBuilder()
+                .appendSuper(super.equals(o))
                 .append(varName, that.varName)
-                .append(getExpression(), that.getExpression())
                 .isEquals();
     }
 
     @Override
     public int hashCode() {
-        return new HashCodeBuilder()
+        return new HashCodeBuilder(17, 37)
+                .appendSuper(super.hashCode())
                 .append(varName)
-                .append(getExpression())
                 .toHashCode();
     }
 
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/LoopStatement.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/LoopStatement.java
index b9995cf80..7c7c8af21 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/LoopStatement.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/LoopStatement.java
@@ -10,6 +10,9 @@
 package io.cloudslang.lang.entities;
 
 import org.apache.commons.lang3.Validate;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.io.Serializable;
 
@@ -37,4 +40,32 @@ public abstract class LoopStatement implements Serializable {
     public String getExpression() {
         return expression;
     }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .append("expression", expression)
+                .toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+
+        if (o == null || getClass() != o.getClass()) return false;
+
+        LoopStatement that = (LoopStatement) o;
+
+        return new EqualsBuilder()
+                .append(expression, that.expression)
+                .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 37)
+                .append(expression)
+                .toHashCode();
+    }
+
 }
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/MapForLoopStatement.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/MapForLoopStatement.java
index a452422fe..72f61fae9 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/MapForLoopStatement.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/MapForLoopStatement.java
@@ -12,6 +12,7 @@ package io.cloudslang.lang.entities;
 import org.apache.commons.lang3.Validate;
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.io.Serializable;
 
@@ -53,28 +54,36 @@ public class MapForLoopStatement extends LoopStatement implements Serializable{
         return valueName;
     }
 
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .appendSuper(super.toString())
+                .append("keyName", keyName)
+                .append("valueName", valueName)
+                .toString();
+    }
+
     @Override
     public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
+        if (this == o) return true;
+
+        if (o == null || getClass() != o.getClass()) return false;
 
         MapForLoopStatement that = (MapForLoopStatement) o;
 
         return new EqualsBuilder()
+                .appendSuper(super.equals(o))
                 .append(keyName, that.keyName)
                 .append(valueName, that.valueName)
-                .append(getExpression(), that.getExpression())
                 .isEquals();
     }
 
     @Override
     public int hashCode() {
-        return new HashCodeBuilder()
+        return new HashCodeBuilder(17, 37)
+                .appendSuper(super.hashCode())
                 .append(keyName)
                 .append(valueName)
-                .append(getExpression())
                 .toHashCode();
     }
 
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ResultNavigation.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ResultNavigation.java
index 301163100..a9776ffe3 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ResultNavigation.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/ResultNavigation.java
@@ -11,6 +11,7 @@ package io.cloudslang.lang.entities;
 
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.io.Serializable;
 
@@ -42,26 +43,34 @@ public class ResultNavigation implements Serializable {
 		return this.presetResult;
 	}
 
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this)
+                .append("nextStepId", nextStepId)
+                .append("presetResult", presetResult)
+                .toString();
+    }
+
     @Override
     public boolean equals(Object o) {
-        if (this == o)
-            return true;
-        if (o == null || getClass() != o.getClass())
-            return false;
+        if (this == o) return true;
+
+        if (o == null || getClass() != o.getClass()) return false;
 
         ResultNavigation that = (ResultNavigation) o;
 
         return new EqualsBuilder()
-                .append(this.nextStepId, that.nextStepId)
-                .append(this.presetResult, that.presetResult)
+                .append(nextStepId, that.nextStepId)
+                .append(presetResult, that.presetResult)
                 .isEquals();
     }
 
     @Override
     public int hashCode() {
-        return new HashCodeBuilder()
+        return new HashCodeBuilder(17, 37)
                 .append(nextStepId)
                 .append(presetResult)
                 .toHashCode();
     }
+
 }
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/InOutParam.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/InOutParam.java
index c4e355dc9..e9a4eefb0 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/InOutParam.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/InOutParam.java
@@ -46,17 +46,32 @@ public abstract class InOutParam implements Serializable {
 
 	@Override
 	public String toString() {
-		return ToStringBuilder.reflectionToString(this);
+		return new ToStringBuilder(this)
+				.append("name", name)
+				.append("value", value)
+				.toString();
 	}
 
 	@Override
 	public boolean equals(Object o) {
-		return EqualsBuilder.reflectionEquals(this, o);
+		if (this == o) return true;
+
+		if (o == null || getClass() != o.getClass()) return false;
+
+		InOutParam that = (InOutParam) o;
+
+		return new EqualsBuilder()
+				.append(name, that.name)
+				.append(value, that.value)
+				.isEquals();
 	}
 
 	@Override
 	public int hashCode() {
-		return HashCodeBuilder.reflectionHashCode(this);
+		return new HashCodeBuilder(17, 37)
+				.append(name)
+				.append(value)
+				.toHashCode();
 	}
 
 }
diff --git a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/Input.java b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/Input.java
index 3ab30e1b5..c2fceb80a 100644
--- a/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/Input.java
+++ b/cloudslang-entities/src/main/java/io/cloudslang/lang/entities/bindings/Input.java
@@ -8,6 +8,10 @@
  */
 package io.cloudslang.lang.entities.bindings;
 
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
 import java.io.Serializable;
 
 /**
@@ -58,4 +62,43 @@ public class Input extends InOutParam {
 		return this.systemPropertyName;
 	}
 
+	@Override
+	public String toString() {
+		return new ToStringBuilder(this)
+				.appendSuper(super.toString())
+				.append("encrypted", encrypted)
+				.append("required", required)
+				.append("overridable", overridable)
+				.append("systemPropertyName", systemPropertyName)
+				.toString();
+	}
+
+	@Override
+	public boolean equals(Object o) {
+		if (this == o) return true;
+
+		if (o == null || getClass() != o.getClass()) return false;
+
+		Input input = (Input) o;
+
+		return new EqualsBuilder()
+				.appendSuper(super.equals(o))
+				.append(encrypted, input.encrypted)
+				.append(required, input.required)
+				.append(overridable, input.overridable)
+				.append(systemPropertyName, input.systemPropertyName)
+				.isEquals();
+	}
+
+	@Override
+	public int hashCode() {
+		return new HashCodeBuilder(17, 37)
+				.appendSuper(super.hashCode())
+				.append(encrypted)
+				.append(required)
+				.append(overridable)
+				.append(systemPropertyName)
+				.toHashCode();
+	}
+
 }