You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by an...@apache.org on 2015/02/06 17:58:24 UTC

[3/5] incubator-brooklyn git commit: Adds EntityAndAttribute.create(...)

Adds EntityAndAttribute.create(...)

It’s nicer to use than the constructor because you don’t need to
specify generics and don’t get warned about it. However, not everyone
is used to such static methods so leaving the constructor as well
for ease of discovery.

Deprecates the old supplier() method, which should really have been 
called create().

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

Branch: refs/heads/master
Commit: 83aa2d62da59401672940fc5542c9721f1b11ffb
Parents: 0ecf677
Author: Aled Sage <al...@gmail.com>
Authored: Fri Feb 6 15:07:40 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Feb 6 15:07:40 2015 +0000

----------------------------------------------------------------------
 .../java/brooklyn/entity/basic/EntityAndAttribute.java   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/83aa2d62/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java b/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
index 71dd822..a7d5a5a 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityAndAttribute.java
@@ -26,7 +26,7 @@ import com.google.common.base.Objects;
 import com.google.common.base.Supplier;
 
 /**
- * A tuple containing an {@link Entity} and an {@link Attribute}, which is assumed to be present on the entity.
+ * A tuple containing an {@link Entity} and an {@link AttributeSensor}, which is assumed to be present on the entity.
  * <p>
  * Allows retrieval of the attribute {@link #getValue() value} or can be used instead where a {@link Supplier} for
  * the attribute value is required.
@@ -36,10 +36,17 @@ public class EntityAndAttribute<T> implements Supplier<T> {
     private final Entity entity;
     private final AttributeSensor<T> attribute;
 
-    public static <T> EntityAndAttribute<T> supplier(Entity entity, AttributeSensor<T> attribute) {
+    public static <T> EntityAndAttribute<T> create(Entity entity, AttributeSensor<T> attribute) {
         return new EntityAndAttribute<T>(entity, attribute);
     }
 
+    /**
+     * @deprecated since 0.7.0; use {@link #create(Entity, AttributeSensor)}; this does not relate to {@link Supplier}
+     */
+    public static <T> EntityAndAttribute<T> supplier(Entity entity, AttributeSensor<T> attribute) {
+        return create(entity, attribute);
+    }
+
     public EntityAndAttribute(Entity entity, AttributeSensor<T> attribute) {
         this.entity = checkNotNull(entity, "entity");
         this.attribute = checkNotNull(attribute, "attribute");