brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] brooklyn-server git commit: Adds equals and hashcode to DslComponent and related classes
Date Thu, 18 Feb 2016 09:45:22 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master a5103bba5 -> a2820e5f6


Adds equals and hashcode to DslComponent and related classes


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/a721273c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/a721273c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/a721273c

Branch: refs/heads/master
Commit: a721273c6eac9f969752babba86d249d97611fac
Parents: 0a5f3e1
Author: Martin Harris <github@nakomis.com>
Authored: Fri Feb 12 16:51:22 2016 +0000
Committer: Martin Harris <github@nakomis.com>
Committed: Wed Feb 17 12:25:33 2016 +0000

----------------------------------------------------------------------
 .../spi/dsl/methods/BrooklynDslCommon.java      | 73 ++++++++++++++++++++
 .../brooklyn/spi/dsl/methods/DslComponent.java  | 56 +++++++++++++++
 2 files changed, 129 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a721273c/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
index 88a1f1d..48ea03f 100644
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
+++ b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
@@ -58,6 +58,7 @@ import org.apache.brooklyn.util.text.Strings;
 import org.apache.commons.beanutils.BeanUtils;
 
 import com.google.common.base.Function;
+import com.google.common.base.Objects;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
@@ -231,6 +232,20 @@ public class BrooklynDslCommon {
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(pattern, args);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            DslFormatString that = DslFormatString.class.cast(obj);
+            return Objects.equal(this.pattern, that.pattern) &&
+                    Arrays.deepEquals(this.args, that.args);
+        }
+
+        @Override
         public String toString() {
             return "$brooklyn:formatString("+
                 JavaStringEscapes.wrapJavaString(pattern)+
@@ -258,6 +273,21 @@ public class BrooklynDslCommon {
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(source, pattern, replacement);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            DslRegexReplacement that = DslRegexReplacement.class.cast(obj);
+            return Objects.equal(this.pattern, that.pattern) &&
+                    Objects.equal(this.replacement, that.replacement) &&
+                    Objects.equal(this.source, that.source);
+        }
+
+        @Override
         public String toString() {
             return String.format("$brooklyn:regexReplace(%s:%s:%s)",source, pattern, replacement);
         }
@@ -344,6 +374,21 @@ public class BrooklynDslCommon {
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(type, fields, config);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            DslObject that = DslObject.class.cast(obj);
+            return Objects.equal(this.type, that.type) &&
+                    Objects.equal(this.fields, that.fields) &&
+                    Objects.equal(this.config, that.config);
+        }
+
+        @Override
         public String toString() {
             return "$brooklyn:object(\""+type.getName()+"\")";
         }
@@ -383,6 +428,20 @@ public class BrooklynDslCommon {
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(providerName, key);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            DslExternal that = DslExternal.class.cast(obj);
+            return Objects.equal(this.providerName, that.providerName) &&
+                    Objects.equal(this.key, that.key);
+        }
+
+        @Override
         public String toString() {
             return "$brooklyn:external("+providerName+", "+key+")";
         }
@@ -429,6 +488,20 @@ public class BrooklynDslCommon {
             }
 
             @Override
+            public int hashCode() {
+                return Objects.hashCode(pattern, replacement);
+            }
+
+            @Override
+            public boolean equals(Object obj) {
+                if (this == obj) return true;
+                if (obj == null || getClass() != obj.getClass()) return false;
+                DslRegexReplacer that = DslRegexReplacer.class.cast(obj);
+                return Objects.equal(this.pattern, that.pattern) &&
+                        Objects.equal(this.replacement, that.replacement);
+            }
+
+            @Override
             public String toString() {
                 return String.format("$brooklyn:regexReplace(%s:%s)", pattern, replacement);
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a721273c/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
index 40fd757..9dd3a04 100644
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
+++ b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/DslComponent.java
@@ -41,6 +41,7 @@ import org.apache.brooklyn.util.core.task.Tasks;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.text.StringEscapes.JavaStringEscapes;
 
+import com.google.common.base.Objects;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableSet;
@@ -207,6 +208,19 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
{
             return (Task<Object>) DependentConfiguration.attributeWhenReady(targetEntity,
(AttributeSensor<?>)targetSensor);
         }
         @Override
+        public int hashCode() {
+            return Objects.hashCode(component, sensorName);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            AttributeWhenReady that = AttributeWhenReady.class.cast(obj);
+            return Objects.equal(this.component, that.component) &&
+                    Objects.equal(this.sensorName, that.sensorName);
+        }
+        @Override
         public String toString() {
             return (component.scope==Scope.THIS ? "" : component.toString()+".") +
                 "attributeWhenReady("+JavaStringEscapes.wrapJavaString(sensorName)+")";
@@ -238,6 +252,20 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
{
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(component, keyName);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            DslConfigSupplier that = DslConfigSupplier.class.cast(obj);
+            return Objects.equal(this.component, that.component) &&
+                    Objects.equal(this.keyName, that.keyName);
+        }
+
+        @Override
         public String toString() {
             return (component.scope==Scope.THIS ? "" : component.toString()+".") + 
                 "config("+JavaStringEscapes.wrapJavaString(keyName)+")";
@@ -274,6 +302,20 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
{
         }
 
         @Override
+        public int hashCode() {
+            return Objects.hashCode(component, sensorName);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) return true;
+            if (obj == null || getClass() != obj.getClass()) return false;
+            DslSensorSupplier that = DslSensorSupplier.class.cast(obj);
+            return Objects.equal(this.component, that.component) &&
+                    Objects.equal(this.sensorName, that.sensorName);
+        }
+
+        @Override
         public String toString() {
             return (component.scope==Scope.THIS ? "" : component.toString()+".") + 
                 "sensor("+JavaStringEscapes.wrapJavaString(sensorName)+")";
@@ -318,6 +360,20 @@ public class DslComponent extends BrooklynDslDeferredSupplier<Entity>
{
         }
     }
 
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(componentId, scopeComponent, scope);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null || getClass() != obj.getClass()) return false;
+        DslComponent that = DslComponent.class.cast(obj);
+        return Objects.equal(this.componentId, that.componentId) &&
+                Objects.equal(this.scopeComponent, that.scopeComponent) &&
+                Objects.equal(this.scope, that.scope);
+    }
 
     @Override
     public String toString() {


Mime
View raw message