brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [53/64] [abbrv] incubator-brooklyn git commit: BROOKLYN-162 - apply org.apache package prefix to utils-groovy
Date Tue, 18 Aug 2015 15:04:02 GMT
BROOKLYN-162 - apply org.apache package prefix to utils-groovy


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

Branch: refs/heads/master
Commit: 412a5a1a8e3e55940783fe415515f02515d184a2
Parents: cf2f7a9
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Aug 18 13:18:00 2015 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Aug 18 14:51:57 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/config/render/RendererHints.java   |   3 +-
 .../enricher/CustomAggregatingEnricher.java     |   2 +-
 .../basic/AbstractAggregatingEnricher.java      |   2 +-
 .../basic/SensorTransformingEnricher.java       |   3 +-
 .../brooklyn/entity/basic/DynamicGroupImpl.java |   2 +-
 .../brooklyn/entity/basic/EntityConfigMap.java  |   2 +-
 .../brooklyn/entity/basic/MethodEffector.java   |   2 +-
 .../entity/group/DynamicFabricImpl.java         |   6 +-
 .../event/basic/DependentConfiguration.java     |   2 +-
 .../event/feed/function/FunctionPollConfig.java |   2 +-
 .../internal/AbstractManagementContext.java     |   3 +-
 .../core/management/internal/EffectorUtils.java |   2 +-
 .../policy/basic/AbstractEntityAdjunct.java     |   2 +-
 .../core/policy/basic/ConfigMapImpl.java        |   2 +-
 .../core/util/BrooklynLanguageExtensions.java   |   3 +-
 .../brooklyn/core/util/flags/FlagUtils.java     |   7 +-
 .../brooklyn/core/util/internal/Repeater.java   |   3 +-
 .../internal/ssh/sshj/SshjClientConnection.java |   3 +-
 .../brooklyn/core/util/task/BasicTask.java      |   3 +-
 .../brooklyn/core/util/task/ScheduledTask.java  |   4 +-
 .../location/basic/AbstractLocation.java        |   2 +-
 .../FixedListMachineProvisioningLocation.java   |   2 +-
 .../LocalhostMachineProvisioningLocation.java   |   4 +-
 .../location/basic/SshMachineLocation.java      |   2 +-
 .../core/util/internal/RepeaterTest.groovy      |   2 +-
 .../enricher/TimeWeightedDeltaEnricher.java     |   2 +-
 .../entity/basic/lifecycle/ScriptHelper.java    |   3 +-
 .../nosql/couchdb/AbstractCouchDBNodeTest.java  |   3 +-
 .../webapp/WebAppLiveIntegrationTest.groovy     |   2 +-
 ...namicWebAppClusterRebindIntegrationTest.java |   3 +-
 .../java/brooklyn/util/GroovyJavaMethods.groovy | 146 -------
 .../brooklyn/util/internal/JavadocDummy.java    |  30 --
 .../brooklyn/util/internal/LanguageUtils.groovy | 383 -------------------
 .../brooklyn/util/internal/TimeExtras.groovy    |  83 ----
 .../brooklyn/util/GroovyJavaMethods.groovy      | 146 +++++++
 .../brooklyn/util/internal/JavadocDummy.java    |  30 ++
 .../brooklyn/util/internal/LanguageUtils.groovy | 383 +++++++++++++++++++
 .../brooklyn/util/internal/TimeExtras.groovy    |  83 ++++
 .../util/internal/LanguageUtilsTest.groovy      | 153 --------
 .../util/internal/PojoTestingFields.java        |  28 --
 .../util/internal/TimeExtrasTest.groovy         |  49 ---
 .../util/internal/LanguageUtilsTest.groovy      | 154 ++++++++
 .../util/internal/PojoTestingFields.java        |  28 ++
 .../util/internal/TimeExtrasTest.groovy         |  49 +++
 44 files changed, 909 insertions(+), 919 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/config/render/RendererHints.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/config/render/RendererHints.java b/core/src/main/java/brooklyn/config/render/RendererHints.java
index 8a3a10b..8787b89 100644
--- a/core/src/main/java/brooklyn/config/render/RendererHints.java
+++ b/core/src/main/java/brooklyn/config/render/RendererHints.java
@@ -25,11 +25,10 @@ import java.util.Set;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.event.AttributeSensor;
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/enricher/CustomAggregatingEnricher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/enricher/CustomAggregatingEnricher.java b/core/src/main/java/brooklyn/enricher/CustomAggregatingEnricher.java
index 4924684..80acfac 100644
--- a/core/src/main/java/brooklyn/enricher/CustomAggregatingEnricher.java
+++ b/core/src/main/java/brooklyn/enricher/CustomAggregatingEnricher.java
@@ -27,11 +27,11 @@ import java.util.Map;
 import org.apache.brooklyn.api.event.AttributeSensor;
 import org.apache.brooklyn.api.event.SensorEventListener;
 import org.apache.brooklyn.core.util.flags.TypeCoercions;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import brooklyn.enricher.basic.AbstractAggregatingEnricher;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.base.Function;
 import com.google.common.base.Throwables;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/enricher/basic/AbstractAggregatingEnricher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/enricher/basic/AbstractAggregatingEnricher.java b/core/src/main/java/brooklyn/enricher/basic/AbstractAggregatingEnricher.java
index 47481bf..bffb126 100644
--- a/core/src/main/java/brooklyn/enricher/basic/AbstractAggregatingEnricher.java
+++ b/core/src/main/java/brooklyn/enricher/basic/AbstractAggregatingEnricher.java
@@ -30,11 +30,11 @@ import org.apache.brooklyn.api.entity.basic.EntityLocal;
 import org.apache.brooklyn.api.event.AttributeSensor;
 import org.apache.brooklyn.api.event.SensorEvent;
 import org.apache.brooklyn.api.event.SensorEventListener;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import brooklyn.entity.trait.Changeable;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/enricher/basic/SensorTransformingEnricher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/enricher/basic/SensorTransformingEnricher.java b/core/src/main/java/brooklyn/enricher/basic/SensorTransformingEnricher.java
index a402074..c6c4398 100644
--- a/core/src/main/java/brooklyn/enricher/basic/SensorTransformingEnricher.java
+++ b/core/src/main/java/brooklyn/enricher/basic/SensorTransformingEnricher.java
@@ -22,13 +22,12 @@ import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.event.AttributeSensor;
 import org.apache.brooklyn.api.event.Sensor;
 import org.apache.brooklyn.api.event.SensorEvent;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
 import org.apache.brooklyn.util.time.Duration;
 
 import groovy.lang.Closure;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.base.Function;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/entity/basic/DynamicGroupImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/DynamicGroupImpl.java b/core/src/main/java/brooklyn/entity/basic/DynamicGroupImpl.java
index 7982402..9451d96 100644
--- a/core/src/main/java/brooklyn/entity/basic/DynamicGroupImpl.java
+++ b/core/src/main/java/brooklyn/entity/basic/DynamicGroupImpl.java
@@ -31,13 +31,13 @@ import org.apache.brooklyn.api.management.Task;
 import org.apache.brooklyn.core.management.internal.CollectionChangeListener;
 import org.apache.brooklyn.core.management.internal.ManagementContextInternal;
 import org.apache.brooklyn.core.util.task.Tasks;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import brooklyn.config.BrooklynLogging;
 import brooklyn.config.BrooklynLogging.LoggingLevel;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java b/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
index 49498e6..409f72f 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityConfigMap.java
@@ -18,8 +18,8 @@
  */
 package brooklyn.entity.basic;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
 
 import java.util.Collections;
 import java.util.LinkedHashMap;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/entity/basic/MethodEffector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/MethodEffector.java b/core/src/main/java/brooklyn/entity/basic/MethodEffector.java
index 0640a02..50b3c86 100644
--- a/core/src/main/java/brooklyn/entity/basic/MethodEffector.java
+++ b/core/src/main/java/brooklyn/entity/basic/MethodEffector.java
@@ -29,13 +29,13 @@ import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.ParameterType;
 import org.apache.brooklyn.core.management.internal.EffectorUtils;
 import org.apache.brooklyn.core.util.flags.TypeCoercions;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.codehaus.groovy.runtime.MethodClosure;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import brooklyn.entity.annotation.EffectorParam;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.collect.Lists;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/entity/group/DynamicFabricImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/group/DynamicFabricImpl.java b/core/src/main/java/brooklyn/entity/group/DynamicFabricImpl.java
index fabc01c..3c4f461 100644
--- a/core/src/main/java/brooklyn/entity/group/DynamicFabricImpl.java
+++ b/core/src/main/java/brooklyn/entity/group/DynamicFabricImpl.java
@@ -18,8 +18,8 @@
  */
 package brooklyn.entity.group;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
-import static brooklyn.util.GroovyJavaMethods.truth;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -32,6 +32,7 @@ import org.apache.brooklyn.api.entity.basic.EntityLocal;
 import org.apache.brooklyn.api.entity.proxying.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.management.Task;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.slf4j.Logger;
@@ -48,7 +49,6 @@ import brooklyn.entity.basic.ServiceStateLogic;
 import brooklyn.entity.effector.Effectors;
 import brooklyn.entity.trait.Changeable;
 import brooklyn.entity.trait.Startable;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicates;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java b/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
index c964bf4..f914bf0 100644
--- a/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
+++ b/core/src/main/java/brooklyn/event/basic/DependentConfiguration.java
@@ -53,6 +53,7 @@ import org.apache.brooklyn.core.util.task.ParallelTask;
 import org.apache.brooklyn.core.util.task.TaskInternal;
 import org.apache.brooklyn.core.util.task.Tasks;
 import org.apache.brooklyn.core.util.task.ValueResolver;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.collections.CollectionFunctionals;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.collections.MutableMap;
@@ -73,7 +74,6 @@ import brooklyn.entity.basic.BrooklynTaskTags;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityInternal;
 import brooklyn.entity.basic.Lifecycle;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Function;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/brooklyn/event/feed/function/FunctionPollConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/event/feed/function/FunctionPollConfig.java b/core/src/main/java/brooklyn/event/feed/function/FunctionPollConfig.java
index e297b02..abd86ef 100644
--- a/core/src/main/java/brooklyn/event/feed/function/FunctionPollConfig.java
+++ b/core/src/main/java/brooklyn/event/feed/function/FunctionPollConfig.java
@@ -24,12 +24,12 @@ import groovy.lang.Closure;
 import java.util.concurrent.Callable;
 
 import org.apache.brooklyn.api.event.AttributeSensor;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.guava.Functionals;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
 
 import brooklyn.event.feed.FeedConfig;
 import brooklyn.event.feed.PollConfig;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.base.Supplier;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/management/internal/AbstractManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/management/internal/AbstractManagementContext.java b/core/src/main/java/org/apache/brooklyn/core/management/internal/AbstractManagementContext.java
index 82e9e49..7765b9a 100644
--- a/core/src/main/java/org/apache/brooklyn/core/management/internal/AbstractManagementContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/management/internal/AbstractManagementContext.java
@@ -76,12 +76,11 @@ import brooklyn.entity.drivers.downloads.BasicDownloadsManager;
 import brooklyn.entity.rebind.RebindManagerImpl;
 
 import org.apache.brooklyn.location.basic.BasicLocationRegistry;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.guava.Maybe;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.base.Function;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/management/internal/EffectorUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/management/internal/EffectorUtils.java b/core/src/main/java/org/apache/brooklyn/core/management/internal/EffectorUtils.java
index 218bc75..9f3b353 100644
--- a/core/src/main/java/org/apache/brooklyn/core/management/internal/EffectorUtils.java
+++ b/core/src/main/java/org/apache/brooklyn/core/management/internal/EffectorUtils.java
@@ -18,7 +18,7 @@
  */
 package org.apache.brooklyn.core.management.internal;
 
-import static brooklyn.util.GroovyJavaMethods.truth;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.lang.reflect.Method;
 import java.util.Arrays;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/policy/basic/AbstractEntityAdjunct.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/policy/basic/AbstractEntityAdjunct.java b/core/src/main/java/org/apache/brooklyn/core/policy/basic/AbstractEntityAdjunct.java
index 78b3820..930a17b 100644
--- a/core/src/main/java/org/apache/brooklyn/core/policy/basic/AbstractEntityAdjunct.java
+++ b/core/src/main/java/org/apache/brooklyn/core/policy/basic/AbstractEntityAdjunct.java
@@ -18,8 +18,8 @@
  */
 package org.apache.brooklyn.core.policy.basic;
 
-import static brooklyn.util.GroovyJavaMethods.truth;
 import static com.google.common.base.Preconditions.checkState;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.util.Collection;
 import java.util.Collections;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/policy/basic/ConfigMapImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/policy/basic/ConfigMapImpl.java b/core/src/main/java/org/apache/brooklyn/core/policy/basic/ConfigMapImpl.java
index cc89ad3..9422638 100644
--- a/core/src/main/java/org/apache/brooklyn/core/policy/basic/ConfigMapImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/core/policy/basic/ConfigMapImpl.java
@@ -18,7 +18,7 @@
  */
 package org.apache.brooklyn.core.policy.basic;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
 
 import java.util.Collections;
 import java.util.Map;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/util/BrooklynLanguageExtensions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/util/BrooklynLanguageExtensions.java b/core/src/main/java/org/apache/brooklyn/core/util/BrooklynLanguageExtensions.java
index 9e1b80e..c2f2200 100644
--- a/core/src/main/java/org/apache/brooklyn/core/util/BrooklynLanguageExtensions.java
+++ b/core/src/main/java/org/apache/brooklyn/core/util/BrooklynLanguageExtensions.java
@@ -21,8 +21,7 @@ package org.apache.brooklyn.core.util;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.brooklyn.core.internal.BrooklynInitialization;
-
-import brooklyn.util.internal.TimeExtras;
+import org.apache.brooklyn.util.internal.TimeExtras;
 
 /** @deprecated since 0.7.0 use {@link BrooklynInitialization} */
 public class BrooklynLanguageExtensions {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/util/flags/FlagUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/util/flags/FlagUtils.java b/core/src/main/java/org/apache/brooklyn/core/util/flags/FlagUtils.java
index 931d1a0..e52d588 100644
--- a/core/src/main/java/org/apache/brooklyn/core/util/flags/FlagUtils.java
+++ b/core/src/main/java/org/apache/brooklyn/core/util/flags/FlagUtils.java
@@ -18,9 +18,9 @@
  */
 package org.apache.brooklyn.core.util.flags;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
-import static brooklyn.util.GroovyJavaMethods.truth;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 import groovy.lang.Closure;
 import groovy.lang.GroovyObject;
 
@@ -38,13 +38,12 @@ import org.apache.brooklyn.api.entity.trait.Configurable;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
 import org.apache.brooklyn.core.util.config.ConfigBag;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.base.Objects;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/util/internal/Repeater.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/util/internal/Repeater.java b/core/src/main/java/org/apache/brooklyn/core/util/internal/Repeater.java
index 178544a..17d1f0f 100644
--- a/core/src/main/java/org/apache/brooklyn/core/util/internal/Repeater.java
+++ b/core/src/main/java/org/apache/brooklyn/core/util/internal/Repeater.java
@@ -30,13 +30,12 @@ import org.apache.brooklyn.core.util.flags.SetFromFlag;
 import org.apache.brooklyn.util.JavaGroovyEquivalents;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.internal.TimeExtras;
 import org.apache.brooklyn.util.time.Duration;
 import org.apache.brooklyn.util.time.Time;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.util.internal.TimeExtras;
-
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.Callables;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/util/internal/ssh/sshj/SshjClientConnection.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/util/internal/ssh/sshj/SshjClientConnection.java b/core/src/main/java/org/apache/brooklyn/core/util/internal/ssh/sshj/SshjClientConnection.java
index c042415..c446514 100644
--- a/core/src/main/java/org/apache/brooklyn/core/util/internal/ssh/sshj/SshjClientConnection.java
+++ b/core/src/main/java/org/apache/brooklyn/core/util/internal/ssh/sshj/SshjClientConnection.java
@@ -30,11 +30,10 @@ import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile;
 import net.schmizz.sshj.userauth.password.PasswordUtils;
 
 import org.apache.brooklyn.core.util.internal.ssh.SshAbstractTool.SshAction;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.base.Objects;
 import com.google.common.net.HostAndPort;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/util/task/BasicTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/util/task/BasicTask.java b/core/src/main/java/org/apache/brooklyn/core/util/task/BasicTask.java
index 27ba9d0..b7c1b1d 100644
--- a/core/src/main/java/org/apache/brooklyn/core/util/task/BasicTask.java
+++ b/core/src/main/java/org/apache/brooklyn/core/util/task/BasicTask.java
@@ -44,6 +44,7 @@ import java.util.concurrent.TimeoutException;
 
 import org.apache.brooklyn.api.management.HasTaskChildren;
 import org.apache.brooklyn.api.management.Task;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.text.Identifiers;
@@ -53,8 +54,6 @@ import org.apache.brooklyn.util.time.Time;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.annotations.Beta;
 import com.google.common.base.Function;
 import com.google.common.base.Objects;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/core/util/task/ScheduledTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/util/task/ScheduledTask.java b/core/src/main/java/org/apache/brooklyn/core/util/task/ScheduledTask.java
index 85818be..35de242 100644
--- a/core/src/main/java/org/apache/brooklyn/core/util/task/ScheduledTask.java
+++ b/core/src/main/java/org/apache/brooklyn/core/util/task/ScheduledTask.java
@@ -18,8 +18,8 @@
  */
 package org.apache.brooklyn.core.util.task;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
-import static brooklyn.util.GroovyJavaMethods.truth;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.util.Map;
 import java.util.concurrent.Callable;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/location/basic/AbstractLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/location/basic/AbstractLocation.java b/core/src/main/java/org/apache/brooklyn/location/basic/AbstractLocation.java
index 9e785c6..d5400e8 100644
--- a/core/src/main/java/org/apache/brooklyn/location/basic/AbstractLocation.java
+++ b/core/src/main/java/org/apache/brooklyn/location/basic/AbstractLocation.java
@@ -18,9 +18,9 @@
  */
 package org.apache.brooklyn.location.basic;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
 import static org.apache.brooklyn.util.JavaGroovyEquivalents.groovyTruth;
 
 import java.io.Closeable;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/location/basic/FixedListMachineProvisioningLocation.java b/core/src/main/java/org/apache/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
index d6b21e9..613e100 100644
--- a/core/src/main/java/org/apache/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
+++ b/core/src/main/java/org/apache/brooklyn/location/basic/FixedListMachineProvisioningLocation.java
@@ -18,7 +18,7 @@
  */
 package org.apache.brooklyn.location.basic;
 
-import static brooklyn.util.GroovyJavaMethods.truth;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.io.Closeable;
 import java.io.File;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/location/basic/LocalhostMachineProvisioningLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/location/basic/LocalhostMachineProvisioningLocation.java b/core/src/main/java/org/apache/brooklyn/location/basic/LocalhostMachineProvisioningLocation.java
index 4d7d91e..97481fa 100644
--- a/core/src/main/java/org/apache/brooklyn/location/basic/LocalhostMachineProvisioningLocation.java
+++ b/core/src/main/java/org/apache/brooklyn/location/basic/LocalhostMachineProvisioningLocation.java
@@ -18,8 +18,8 @@
  */
 package org.apache.brooklyn.location.basic;
 
-import static brooklyn.util.GroovyJavaMethods.elvis;
-import static brooklyn.util.GroovyJavaMethods.truth;
+import static org.apache.brooklyn.util.GroovyJavaMethods.elvis;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.io.File;
 import java.net.InetAddress;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/main/java/org/apache/brooklyn/location/basic/SshMachineLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/location/basic/SshMachineLocation.java b/core/src/main/java/org/apache/brooklyn/location/basic/SshMachineLocation.java
index 62a83d4..ef8c6d8 100644
--- a/core/src/main/java/org/apache/brooklyn/location/basic/SshMachineLocation.java
+++ b/core/src/main/java/org/apache/brooklyn/location/basic/SshMachineLocation.java
@@ -18,7 +18,7 @@
  */
 package org.apache.brooklyn.location.basic;
 
-import static brooklyn.util.GroovyJavaMethods.truth;
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
 
 import java.io.Closeable;
 import java.io.File;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/core/src/test/java/org/apache/brooklyn/core/util/internal/RepeaterTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/util/internal/RepeaterTest.groovy b/core/src/test/java/org/apache/brooklyn/core/util/internal/RepeaterTest.groovy
index 2345e35..13b1ba4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/util/internal/RepeaterTest.groovy
+++ b/core/src/test/java/org/apache/brooklyn/core/util/internal/RepeaterTest.groovy
@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit
 import org.apache.brooklyn.core.util.internal.Repeater;
 import org.testng.annotations.Test
 
-import brooklyn.util.internal.TimeExtras;
+import org.apache.brooklyn.util.internal.TimeExtras;
 import org.apache.brooklyn.util.time.Duration;
 
 import com.google.common.base.Stopwatch

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java b/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
index e4637f5..f5dc349 100644
--- a/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
+++ b/policy/src/main/java/brooklyn/enricher/TimeWeightedDeltaEnricher.java
@@ -25,6 +25,7 @@ import org.apache.brooklyn.api.event.AttributeSensor;
 import org.apache.brooklyn.api.event.Sensor;
 import org.apache.brooklyn.api.event.SensorEvent;
 import org.apache.brooklyn.core.util.flags.SetFromFlag;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.javalang.JavaClassNames;
 import org.apache.brooklyn.util.time.Duration;
 import org.slf4j.Logger;
@@ -32,7 +33,6 @@ import org.slf4j.LoggerFactory;
 
 import brooklyn.enricher.basic.AbstractTypeTransformingEnricher;
 import brooklyn.enricher.basic.YamlTimeWeightedDeltaEnricher;
-import brooklyn.util.GroovyJavaMethods;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Function;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java b/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java
index dcf3658..5ab0ace 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/lifecycle/ScriptHelper.java
@@ -46,14 +46,13 @@ import org.slf4j.LoggerFactory;
 import brooklyn.entity.basic.BrooklynTaskTags;
 
 import org.apache.brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.util.GroovyJavaMethods;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.exceptions.RuntimeInterruptedException;
 import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.text.Strings;
 
-import brooklyn.util.GroovyJavaMethods;
-
 import com.google.common.annotations.Beta;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
index c5c732b..e967899 100644
--- a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
+++ b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
@@ -19,6 +19,7 @@
 package org.apache.brooklyn.entity.nosql.couchdb;
 
 import org.apache.brooklyn.test.entity.TestApplication;
+import org.apache.brooklyn.util.internal.TimeExtras;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -30,8 +31,6 @@ import brooklyn.entity.basic.Entities;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 
-import brooklyn.util.internal.TimeExtras;
-
 /**
  * CouchDB test framework for integration and live tests.
  */

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy
index 769e5a5..6e49882 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/WebAppLiveIntegrationTest.groovy
@@ -44,7 +44,7 @@ import org.apache.brooklyn.api.location.Location
 import org.apache.brooklyn.location.basic.BasicLocationRegistry
 import org.apache.brooklyn.test.TestUtils
 import org.apache.brooklyn.test.entity.TestApplicationImpl
-import brooklyn.util.internal.TimeExtras
+import org.apache.brooklyn.util.internal.TimeExtras
 
 /**
  * This tests that we can run jboss entity on AWS.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
index 588a890..4d47ee2 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/webapp/jboss/ControlledDynamicWebAppClusterRebindIntegrationTest.java
@@ -37,6 +37,7 @@ import org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster;
 import org.apache.brooklyn.test.TestResourceUnavailableException;
 import org.apache.brooklyn.test.WebAppMonitor;
 import org.apache.brooklyn.test.entity.TestApplication;
+import org.apache.brooklyn.util.internal.TimeExtras;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
@@ -50,8 +51,6 @@ import brooklyn.entity.rebind.RebindTestUtils;
 
 import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 
-import brooklyn.util.internal.TimeExtras;
-
 import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/brooklyn/util/GroovyJavaMethods.groovy
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/brooklyn/util/GroovyJavaMethods.groovy b/utils/groovy/src/main/java/brooklyn/util/GroovyJavaMethods.groovy
deleted file mode 100644
index a62ba87..0000000
--- a/utils/groovy/src/main/java/brooklyn/util/GroovyJavaMethods.groovy
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.util;
-
-import static brooklyn.util.GroovyJavaMethods.truth
-
-import java.util.concurrent.Callable
-
-import org.apache.brooklyn.util.concurrent.CallableFromRunnable;
-
-import com.google.common.base.Function
-import com.google.common.base.Predicate
-
-/** handy methods available in groovy packaged so they can be consumed from java,
- *  and other conversion/conveniences; but see JavaGroovyEquivalents for faster alternatives */
-public class GroovyJavaMethods {
-
-    //TODO use named subclasses, would that be more efficient?
-
-    // TODO xFromY methods not in correct class: they are not "handy method available in groovy"?
-    public static Closure closureFromRunnable(final Runnable job) {
-        return {
-            if (job in Callable) { return job.call() }
-            else { job.run(); null; }
-        };
-    }
-    
-    public static Closure closureFromCallable(final Callable job) {
-        return { job.call(); };
-    }
-
-    public static <T> Closure<T> closureFromFunction(final Function<?,T> job) {
-        return { it -> return job.apply(it); };
-    }
-
-    public static <T> Callable<T> callableFromClosure(final Closure<T> job) {
-        return job as Callable;
-    }
-
-    public static <T> Callable<T> callableFromRunnable(final Runnable job) {
-        return (job in Callable) ? callableFromClosure(job) : CallableFromRunnable.newInstance(job, null);
-    }
-
-    public static <T> Predicate<T> predicateFromClosure(final Closure<Boolean> job) {
-        // TODO using `Predicate<T>` on the line below gives "unable to resolve class T"
-        return new Predicate<Object>() {
-            public boolean apply(Object input) {
-                return job.call(input);
-            }
-        };
-    }
-
-    public static <F,T> Function<F,T> functionFromClosure(final Closure<T> job) {
-        // TODO using `Function<F,T>` on the line below gives "unable to resolve class T"
-        return new Function<Object,Object>() {
-            public Object apply(Object input) {
-                return job.call(input);
-            }
-        };
-    }
-
-    public static <T> Predicate<T> castToPredicate(Object o) {
-        if (o in Closure) {
-            return predicateFromClosure(o);
-        } else {
-            return (Predicate<T>) o;
-        }
-    }
-
-    public static <T> Closure castToClosure(Object o) {
-        if (o == null) {
-            return o;
-        } else if (o in Closure) {
-            return o;
-        } else if (o instanceof Runnable) {
-            return closureFromRunnable((Runnable)o);
-        } else if (o instanceof Callable) {
-            return closureFromCallable((Callable)o); 
-        } else if (o instanceof Function) {
-            return closureFromFunction((Function)o); 
-        } else {
-            throw new IllegalArgumentException("Cannot convert to closure: o="+o+"; type="+(o != null ? o.getClass() : null));
-        }
-    }
-
-/* alternatives to above; but I think the above is more efficient?  (even more efficient if moved from java to groovy)  --alex jun 2012
-    public static <K,T> Function<K,T> functionFromClosure(final Closure<T> job) {
-        return job as Function;
-    }
-
-    public static <T> Predicate<T> predicateFromClosure(final Closure<Boolean> job) {
-        return job as Predicate;
-    }
-*/
-    
-    public static Predicate<Object> truthPredicate() {
-        return new Predicate<Object>() {
-           @Override public boolean apply(Object input) {
-               return truth(input);
-           }
-        };
-    }
-    
-    public static boolean truth(Object o) {
-        if (o) return true;
-        return false;
-    }
-
-    public static <T> T elvis(Object preferred, Object fallback) {
-        return fix(preferred ?: fallback);
-    }
-    
-    public static <T> T elvis(Object... preferences) {
-        if (preferences.length == 0) throw new IllegalArgumentException("preferences must not be empty for elvis");
-        for (Object contender : preferences) {
-            if (contender) return fix(contender);
-        }
-        return fix(preferences[preferences.size()-1]);
-    }
-    
-    public static <T> T fix(Object o) {
-        if (o in GString) return (o as String);
-        return o;
-    }
-    
-    // args is expected to be an array, but for groovy compilation reasons it's not declared as such in the signature :-(
-    public static <T> T invokeMethodOnMetaClass(Object target, String methodName, Object args) {
-        return target.metaClass.invokeMethod(target, methodName, args);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/brooklyn/util/internal/JavadocDummy.java
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/brooklyn/util/internal/JavadocDummy.java b/utils/groovy/src/main/java/brooklyn/util/internal/JavadocDummy.java
deleted file mode 100644
index 3ccdce8..0000000
--- a/utils/groovy/src/main/java/brooklyn/util/internal/JavadocDummy.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.util.internal;
-
-/** Maven Central requires javadoc to promote as a release. This seemed to happen when this was built by maven as a bundle,
- * but now that it is built as a jar it does not. This class exists only to provide that javadoc.
- * <p>
- * Note the groovy code does javadoc but the maven build is not picking it up. It *is* generated as part of the site build.
- */
-public class JavadocDummy {
-
-    private JavadocDummy() {}
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/brooklyn/util/internal/LanguageUtils.groovy
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/brooklyn/util/internal/LanguageUtils.groovy b/utils/groovy/src/main/java/brooklyn/util/internal/LanguageUtils.groovy
deleted file mode 100644
index 579f23d..0000000
--- a/utils/groovy/src/main/java/brooklyn/util/internal/LanguageUtils.groovy
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.util.internal
-
-import java.lang.reflect.Field
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier
-import java.util.Collection;
-import java.util.concurrent.atomic.AtomicLong
-
-import org.apache.brooklyn.util.javalang.Reflections;
-import org.apache.brooklyn.util.text.Identifiers
-
-import com.google.common.annotations.Beta
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-/**
- * Useful Groovy utility methods.
- * 
- * @deprecated since 0.5; requires thorough review for what will be kept.
- *             e.g. consider instead using guava's {@link com.google.common.collect.Multimap} instead of addToMapOfSets etc
- */
-@Deprecated
-@Beta
-public class LanguageUtils {
-    // For unique identifiers
-    private static final AtomicLong seed = new AtomicLong(0L)
-
-    public static <T> T getRequiredField(String name, Map<?,?> m) {
-        if (!m.containsKey(name))
-            throw new IllegalArgumentException("a parameter '"+name+"' was required in the argument to this function")
-        m.get name
-    }
-
-    public static <T> T getOptionalField(String name, Map<?,?> m, T defaultValue=null) {
-        m.get(name) ?: defaultValue
-    }
-
-    public static <T> T getPropertySafe(Object target, String name, T defaultValue=null) {
-        target.hasProperty(name)?.getProperty(target) ?: defaultValue
-    }
-
-    //TODO find with annotation
-
-    public static byte[] serialize(Object orig) {
-        if (orig == null) return null;
-
-        // Write the object out to a byte array
-        ByteArrayOutputStream fbos = []
-        ObjectOutputStream out = new ObjectOutputStream(fbos);
-        out.writeObject(orig);
-        out.flush();
-        out.close();
-        return fbos.toByteArray();
-    }
-
-    public static <T> T deserialize(byte[] bytes, ClassLoader classLoader) {
-        if (bytes == null) return null;
-
-        ObjectInputStream ins =
-                //new ObjectInputStreamWithLoader(new FastByteArrayInputStream(bytes, bytes.length), classLoader);
-                new ObjectInputStream(new ByteArrayInputStream(bytes));
-        (T) ins.readObject();
-    }
-
-    /**
-     * @deprecated use Identifiers.makeRandomId(8)
-     */
-    @Deprecated
-    public static String newUid() { Identifiers.makeRandomId(8) }
-
-    public static Map setFieldsFromMap(Object target, Map fieldValues) {
-        Map unused = [:]
-        fieldValues.each {
-            //            println "looking for "+it.key+" in "+target+": "+target.metaClass.hasProperty(it.key)
-            target.hasProperty(it.key) ? target.(it.key) = it.value : unused << it
-        }
-        unused
-    }
-
-    /**
-     * Adds the given value to a collection in the map under the key.
-     * 
-     * A collection (as {@link LinkedHashMap}) will be created if necessary,
-     * synchronized on map for map access/change and set for addition there
-     *
-     * @return the updated set (instance, not copy)
-     * 
-     * @deprecated since 0.5; use {@link HashMultimap}, and {@link Multimaps#synchronizedSetMultimap(com.google.common.collect.SetMultimap)}
-     */
-    @Deprecated
-    public static <K,V> Set<V> addToMapOfSets(Map<K,Set<V>> map, K key, V valueInCollection) {
-        Set<V> coll;
-        synchronized (map) {
-            coll = map.get(key)
-            if (coll==null) {
-                coll = new LinkedHashSet<V>()
-                map.put(key, coll)
-            }
-            if (coll.isEmpty()) {
-                synchronized (coll) {
-                    coll.add(valueInCollection)
-                }
-                //if collection was empty then add to the collection while holding the map lock, to prevent removal
-                return coll
-            }
-        }
-        synchronized (coll) {
-            if (!coll.isEmpty()) {
-                coll.add(valueInCollection)
-                return coll;
-            }
-        }
-        //if was empty, recurse, because someone else might be removing the collection
-        return addToMapOfSets(map, key, valueInCollection);
-    }
-
-    /**
-     * as {@link #addToMapOfSets(Map, Object, Object)} but for {@link ArrayList}
-     * 
-     * @deprecated since 0.5; use {@link ArrayListMultimap}, and {@link Multimaps#synchronizedListMultimap(com.google.common.collect.ListMultimap)}
-     */
-    @Deprecated
-    public static <K,V> List<V> addToMapOfLists(Map<K,List<V>> map, K key, V valueInCollection) {
-        List<V> coll;
-        synchronized (map) {
-            coll = map.get(key)
-            if (coll==null) {
-                coll = new ArrayList<V>()
-                map.put(key, coll)
-            }
-            if (coll.isEmpty()) {
-                synchronized (coll) {
-                    coll.add(valueInCollection)
-                }
-                //if collection was empty then add to the collection while holding the map lock, to prevent removal
-                return coll
-            }
-        }
-        synchronized (coll) {
-            if (!coll.isEmpty()) {
-                coll.add(valueInCollection)
-                return coll;
-            }
-        }
-        //if was empty, recurse, because someone else might be removing the collection
-        return addToMapOfLists(map, key, valueInCollection);
-    }
-
-    /**
-     * Removes the given value from a collection in the map under the key.
-     *
-     * @return the updated set (instance, not copy)
-     * 
-     * @deprecated since 0.5; use {@link ArrayListMultimap} or {@link HashMultimap}, and {@link Multimaps#synchronizedListMultimap(com.google.common.collect.ListMultimap)} etc
-     */
-    @Deprecated
-    public static <K,V> boolean removeFromMapOfCollections(Map<K,? extends Collection<V>> map, K key, V valueInCollection) {
-        Collection<V> coll;
-        synchronized (map) {
-            coll = map.get(key)
-            if (coll==null) return false;
-        }
-        boolean result;
-        synchronized (coll) {
-            result = coll.remove(valueInCollection)
-        }
-        if (coll.isEmpty()) {
-            synchronized (map) {
-                synchronized (coll) {
-                    if (coll.isEmpty()) {
-                        //only remove from the map if no one is adding to the collection or to the map, and the collection is still in the map
-                        if (map.get(key)==coll) {
-                            map.remove(key)
-                        }
-                    }
-                }
-            }
-        }
-        return result;
-    }
-
-    /**
-     * Visits all fields of a given object, recursively.
-     *
-     * For collections, arrays, and maps it visits the items within, passing null for keys where it isn't a map.
-     */
-    public static void visitFields(Object o, FieldVisitor fv, Collection<Object> objectsToSkip=([] as Set)) {
-        if (o == null || objectsToSkip.contains(o)) return
-        objectsToSkip << o
-        if (o in String) return
-        if (o in Map) {
-            o.each { key, value ->
-                fv.visit(o, key.toString(), value)
-                visitFields(value, fv, objectsToSkip)
-            }
-        } else if ((o in Collection) || (o.getClass().isArray())) {
-            o.each {
-                entry ->
-                fv.visit(o, null, entry)
-                visitFields(entry, fv, objectsToSkip)
-            }
-        } else {
-            o.getClass().getDeclaredFields().each {
-                Field field ->
-                if ((field.getModifiers() & Modifier.STATIC) || field.isSynthetic()) return;  //skip static
-                field.setAccessible true
-                def v = field.get(o);
-                fv.visit(o, field.name, v)
-                visitFields(v, fv, objectsToSkip)
-            }
-        }
-    }
-
-    public interface FieldVisitor {
-        /** Invoked by visitFields; fieldName will be null for collections */
-        public void visit(Object parent, String fieldName, Object value)
-    }
-
-    /**
-     * Iterates through two collections simultaneously, passing both args to code.
-     * 
-     * <pre>
-     * a = ['a','b']; b=[1,2];
-     * assert ['a1','b2'] == forboth(a,b) { x,y -> x+y }
-     * </pre>
-     */
-    public static Collection forBoth(Collection l1, Collection l2, Closure code) {
-        def result=[]
-        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i]) ) }
-        result
-    }
-
-    public static Collection forBothWithIndex(Collection l1, Collection l2, Closure code) {
-        def result=[]
-        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i], i) ) }
-        result
-    }
-
-    public static Collection forBoth(Object[] l1, Object[] l2, Closure code) {
-        def result=[]
-        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i]) ) }
-        result
-    }
-
-    public static Collection forBothWithIndex(Object[] l1, Object[] l2, Closure code) {
-        def result=[]
-        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i], i) ) }
-        result
-    }
-
-    /** return value used to indicate that there is no such field */
-    public static final Object NO_SUCH_FIELD = new Object();
-
-    /**
-     * Default field getter.
-     *
-     * Delegates to {@code object[field]} (which will invoke a getter if one exists, in groovy),
-     * unless field starts with {@literal @} in which case it looks up the actual java field (bypassing getter).
-     * <p>
-     * Can be extended as needed when passed to {@link #equals(Object, Object, Class, String[])}
-     */
-    public static final Closure DEFAULT_FIELD_GETTER = { Object object, Object field ->
-        try {
-            if ((field in String) && field.startsWith("@")) {
-                return object.@"${field.substring(1)}"
-            }
-            return object[field]
-        } catch (Exception e) {
-            return NO_SUCH_FIELD
-        }
-    }
-
-    /**
-     * Checks equality of o1 and o2 with respect to the named fields, optionally enforcing a common superclass
-     * and using a custom field-getter.
-     *
-     * Other types can be supplied if they are supported by {@code object[field]} (what the {@link #DEFAULT_FIELD_GETTER} does)
-     * or if the {@literal optionalGetter} handles it. Note that {@code object[field]} causes invocation of {@code object.getAt(field)}
-     * (which can be provided on the object for non-strings - this is preferred to an optionalGetter, generally)
-     * looking for {@code object.getXxx()}, where field is a string {@literal xxx}, then {@code object.xxx}.
-     * <p>
-     * One exception is that field names which start with {@literal @} get the field directly according to {@link #DEFAULT_FIELD_GETTER},
-     * but use with care on private fields, as they must be on the object and not a superclass, and with groovy properties
-     * (formerly known as package-private, i.e. with no access modifiers) because they become private fields.
-     * <p>
-     * For example
-     * <pre>
-     * public class Foo {
-     *   Object bar;
-     *   public boolean equals(Object other) { LangaugeUtils.equals(this, other, Foo.class, ["bar"]); }
-     *   public int hashCode() { LangaugeUtils.hashCode(this, ["bar"]); }
-     * }
-     * </pre>
-     *
-     * @param o1 one object to compare
-     * @param o2 other object to compare
-     * @param optionalCommonSuperClass if supplied, returns false unless both objects are instances of the given type;
-     *     (if not supplied it effectively does duck typing, returning false if any field is not present)
-     * @param optionalGetter if supplied, a closure which takes (object, field) and returns the value of field on object;
-     *  should return static {@link #NO_SUCH_FIELD} if none found;
-     *  recommended to delegate to {@link #DEFAULT_FIELD_GETTER} at least for strings (or for anything)
-     * @param fields typically a list of strings being names of fields on the class to compare
-     * @return true if the two objects are equal in all indicated fields, and conform to the optionalCommonSuperClass if supplied
-     */
-    public static boolean equals(Object o1, Object o2, Class<?> optionalCommonSuperClass=null, Closure optionalGetter=null, Iterable<Object> fieldNames) {
-        if (o1==null) return o2==null;
-        if (o2==null) return false;
-        if (optionalCommonSuperClass) {
-            if (!(o1 in optionalCommonSuperClass) || !(o2 in optionalCommonSuperClass)) return false
-        }
-        Closure get = optionalGetter ?: DEFAULT_FIELD_GETTER
-        for (it in fieldNames) {
-            def v1 = get.call(o1, it)
-            if (v1==NO_SUCH_FIELD) return false
-            if (v1!=get.call(o2, it)) return false
-        }
-        return true
-    }
-
-    public static boolean equals(Object o1, Object o2, Class<?> optionalCommonSuperClass=null, Closure optionalGetter=null, Object[] fieldNames) {
-        return equals(o1, o2, optionalCommonSuperClass, optionalGetter, Arrays.asList(fieldNames) )
-    }
-
-    /**
-     * Generates a hashcode for an object.
-     * 
-     * Similar to {@link com.google.common.base.Objects#hashCode()} but taking field <em>names</em> and an optional getter,
-     * with the same rich groovy semantics as described in {@link #equals(Object, Object, Class)}.
-     */
-    public static int hashCode(Object o, Closure optionalGetter=null, Collection<Object> fieldNames) {
-        if (o==null) return 0;
-        Closure get = optionalGetter ?: DEFAULT_FIELD_GETTER
-        int result = 1;
-        for (it in fieldNames) {
-            def v1 = get.call(o, it)
-            if (v1==NO_SUCH_FIELD)
-                throw new NoSuchFieldError("Cannot access $it on "+o.getClass());
-            result = 31 * result + (it == null ? 0 : it.hashCode());
-        }
-        result
-    }
-
-    public static int hashCode(Object o, Closure optionalGetter=null, Object[] fieldNames) {
-        hashCode(o, optionalGetter, Arrays.asList(fieldNames))
-    }
-    
-    /** Default String representation is simplified name of class, together with selected fields. */
-    public static String toString(Object o, Closure optionalGetter=null, Collection<? extends CharSequence> fieldNames) {
-        if (o==null) return null;
-        Closure get = optionalGetter ?: DEFAULT_FIELD_GETTER
-        
-        StringBuilder result = new StringBuilder();
-        result.append(o.getClass().getSimpleName());
-        if (result.length() == 0) result.append(o.getClass().getName());
-        List<Object> fieldVals = fieldNames.collect {
-                Object v = get.call(o, it);
-                return (v != null) ? it+"="+v : null;
-        }
-        result.append("[").append(Joiner.on(",").skipNulls().join(fieldVals)).append("]");
-        return result.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/brooklyn/util/internal/TimeExtras.groovy
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/brooklyn/util/internal/TimeExtras.groovy b/utils/groovy/src/main/java/brooklyn/util/internal/TimeExtras.groovy
deleted file mode 100644
index 1cf9f07..0000000
--- a/utils/groovy/src/main/java/brooklyn/util/internal/TimeExtras.groovy
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.util.internal
-
-import groovy.time.TimeDuration
-
-import java.util.concurrent.TimeUnit
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import org.apache.brooklyn.util.time.Time
-
-
-/**
- * Classloading this class will cause multiply/add to be made available on TimeDuration.
- * For example, I could write: 2*TimeUnit.MINUTES+5*TimeUnit.SECONDS.
- * 
- * That is why nothing seems to use this class, because the methods it defines are not 
- * on this class!
- * 
- * @author alex
- * 
- * @deprecated since 0.6.0 - just use brooklyn.util.time.Duration, simpler and easier to configure, and avoids language problems
- */
-@Deprecated
-class TimeExtras {
-    public static final Logger log = LoggerFactory.getLogger(TimeExtras.class);
-    
-    public static void init() {
-        Number.metaClass.multiply << { TimeUnit t -> new TimeDuration(t.toMillis(intValue())) }
-        Number.metaClass.multiply << { TimeDuration t -> t.multiply(doubleValue()) }
-        Integer.metaClass.multiply << { TimeUnit t -> new TimeDuration(t.toMillis(intValue())) }
-        
-        TimeDuration.metaClass.multiply << { Number n -> new TimeDuration( (int)(toMilliseconds()*n) ) }
-        TimeDuration.metaClass.constructor << { long millis ->
-            def shift = { int modulus -> int v=millis%modulus; millis/=modulus; v }
-            def l = [shift(1000), shift(60), shift(60), shift(24), (int)millis]
-            Collections.reverse(l)
-            l as TimeDuration
-        }
-    }
-    
-    static { init(); }
-    
-    /** creates a duration object
-     * <p>
-     * fix for irritating classloading/metaclass order 
-     * where an int may get constructed too early and not have the multiply syntax available
-     * (because grail is invoked?; if e.g. 5*SECONDS throws an error, try duration(5, SECONDS)  */ 
-    public static TimeDuration duration(int value, TimeUnit unit) {
-        return new TimeDuration(0, 0, 0, (int)unit.toMillis(value));
-    }
-    
-    public static final TimeDuration ONE_SECOND = duration(1, TimeUnit.SECONDS);
-    public static final TimeDuration FIVE_SECONDS = duration(5, TimeUnit.SECONDS);
-    public static final TimeDuration TEN_SECONDS = duration(10, TimeUnit.SECONDS);
-    public static final TimeDuration THIRTY_SECONDS = duration(30, TimeUnit.SECONDS);
-    public static final TimeDuration ONE_MINUTE = duration(1, TimeUnit.MINUTES);
-    public static final TimeDuration TWO_MINUTES = duration(2, TimeUnit.MINUTES);
-    public static final TimeDuration FIVE_MINUTES = duration(5, TimeUnit.MINUTES);
-
-    public static void sleep(TimeDuration duration) {
-        Time.sleep(duration.toMilliseconds());
-    }    
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/org/apache/brooklyn/util/GroovyJavaMethods.groovy
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/org/apache/brooklyn/util/GroovyJavaMethods.groovy b/utils/groovy/src/main/java/org/apache/brooklyn/util/GroovyJavaMethods.groovy
new file mode 100644
index 0000000..996e4f2
--- /dev/null
+++ b/utils/groovy/src/main/java/org/apache/brooklyn/util/GroovyJavaMethods.groovy
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.util;
+
+import static org.apache.brooklyn.util.GroovyJavaMethods.truth;
+
+import java.util.concurrent.Callable
+
+import org.apache.brooklyn.util.concurrent.CallableFromRunnable;
+
+import com.google.common.base.Function
+import com.google.common.base.Predicate
+
+/** handy methods available in groovy packaged so they can be consumed from java,
+ *  and other conversion/conveniences; but see JavaGroovyEquivalents for faster alternatives */
+public class GroovyJavaMethods {
+
+    //TODO use named subclasses, would that be more efficient?
+
+    // TODO xFromY methods not in correct class: they are not "handy method available in groovy"?
+    public static Closure closureFromRunnable(final Runnable job) {
+        return {
+            if (job in Callable) { return job.call() }
+            else { job.run(); null; }
+        };
+    }
+    
+    public static Closure closureFromCallable(final Callable job) {
+        return { job.call(); };
+    }
+
+    public static <T> Closure<T> closureFromFunction(final Function<?,T> job) {
+        return { it -> return job.apply(it); };
+    }
+
+    public static <T> Callable<T> callableFromClosure(final Closure<T> job) {
+        return job as Callable;
+    }
+
+    public static <T> Callable<T> callableFromRunnable(final Runnable job) {
+        return (job in Callable) ? callableFromClosure(job) : CallableFromRunnable.newInstance(job, null);
+    }
+
+    public static <T> Predicate<T> predicateFromClosure(final Closure<Boolean> job) {
+        // TODO using `Predicate<T>` on the line below gives "unable to resolve class T"
+        return new Predicate<Object>() {
+            public boolean apply(Object input) {
+                return job.call(input);
+            }
+        };
+    }
+
+    public static <F,T> Function<F,T> functionFromClosure(final Closure<T> job) {
+        // TODO using `Function<F,T>` on the line below gives "unable to resolve class T"
+        return new Function<Object,Object>() {
+            public Object apply(Object input) {
+                return job.call(input);
+            }
+        };
+    }
+
+    public static <T> Predicate<T> castToPredicate(Object o) {
+        if (o in Closure) {
+            return predicateFromClosure(o);
+        } else {
+            return (Predicate<T>) o;
+        }
+    }
+
+    public static <T> Closure castToClosure(Object o) {
+        if (o == null) {
+            return o;
+        } else if (o in Closure) {
+            return o;
+        } else if (o instanceof Runnable) {
+            return closureFromRunnable((Runnable)o);
+        } else if (o instanceof Callable) {
+            return closureFromCallable((Callable)o); 
+        } else if (o instanceof Function) {
+            return closureFromFunction((Function)o); 
+        } else {
+            throw new IllegalArgumentException("Cannot convert to closure: o="+o+"; type="+(o != null ? o.getClass() : null));
+        }
+    }
+
+/* alternatives to above; but I think the above is more efficient?  (even more efficient if moved from java to groovy)  --alex jun 2012
+    public static <K,T> Function<K,T> functionFromClosure(final Closure<T> job) {
+        return job as Function;
+    }
+
+    public static <T> Predicate<T> predicateFromClosure(final Closure<Boolean> job) {
+        return job as Predicate;
+    }
+*/
+    
+    public static Predicate<Object> truthPredicate() {
+        return new Predicate<Object>() {
+           @Override public boolean apply(Object input) {
+               return truth(input);
+           }
+        };
+    }
+    
+    public static boolean truth(Object o) {
+        if (o) return true;
+        return false;
+    }
+
+    public static <T> T elvis(Object preferred, Object fallback) {
+        return fix(preferred ?: fallback);
+    }
+    
+    public static <T> T elvis(Object... preferences) {
+        if (preferences.length == 0) throw new IllegalArgumentException("preferences must not be empty for elvis");
+        for (Object contender : preferences) {
+            if (contender) return fix(contender);
+        }
+        return fix(preferences[preferences.size()-1]);
+    }
+    
+    public static <T> T fix(Object o) {
+        if (o in GString) return (o as String);
+        return o;
+    }
+    
+    // args is expected to be an array, but for groovy compilation reasons it's not declared as such in the signature :-(
+    public static <T> T invokeMethodOnMetaClass(Object target, String methodName, Object args) {
+        return target.metaClass.invokeMethod(target, methodName, args);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/JavadocDummy.java
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/JavadocDummy.java b/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/JavadocDummy.java
new file mode 100644
index 0000000..04f663e
--- /dev/null
+++ b/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/JavadocDummy.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.util.internal;
+
+/** Maven Central requires javadoc to promote as a release. This seemed to happen when this was built by maven as a bundle,
+ * but now that it is built as a jar it does not. This class exists only to provide that javadoc.
+ * <p>
+ * Note the groovy code does javadoc but the maven build is not picking it up. It *is* generated as part of the site build.
+ */
+public class JavadocDummy {
+
+    private JavadocDummy() {}
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/412a5a1a/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/LanguageUtils.groovy
----------------------------------------------------------------------
diff --git a/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/LanguageUtils.groovy b/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/LanguageUtils.groovy
new file mode 100644
index 0000000..5e0b356
--- /dev/null
+++ b/utils/groovy/src/main/java/org/apache/brooklyn/util/internal/LanguageUtils.groovy
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.util.internal
+
+import java.lang.reflect.Field
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicLong
+
+import org.apache.brooklyn.util.javalang.Reflections;
+import org.apache.brooklyn.util.text.Identifiers
+
+import com.google.common.annotations.Beta
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Useful Groovy utility methods.
+ * 
+ * @deprecated since 0.5; requires thorough review for what will be kept.
+ *             e.g. consider instead using guava's {@link com.google.common.collect.Multimap} instead of addToMapOfSets etc
+ */
+@Deprecated
+@Beta
+public class LanguageUtils {
+    // For unique identifiers
+    private static final AtomicLong seed = new AtomicLong(0L)
+
+    public static <T> T getRequiredField(String name, Map<?,?> m) {
+        if (!m.containsKey(name))
+            throw new IllegalArgumentException("a parameter '"+name+"' was required in the argument to this function")
+        m.get name
+    }
+
+    public static <T> T getOptionalField(String name, Map<?,?> m, T defaultValue=null) {
+        m.get(name) ?: defaultValue
+    }
+
+    public static <T> T getPropertySafe(Object target, String name, T defaultValue=null) {
+        target.hasProperty(name)?.getProperty(target) ?: defaultValue
+    }
+
+    //TODO find with annotation
+
+    public static byte[] serialize(Object orig) {
+        if (orig == null) return null;
+
+        // Write the object out to a byte array
+        ByteArrayOutputStream fbos = []
+        ObjectOutputStream out = new ObjectOutputStream(fbos);
+        out.writeObject(orig);
+        out.flush();
+        out.close();
+        return fbos.toByteArray();
+    }
+
+    public static <T> T deserialize(byte[] bytes, ClassLoader classLoader) {
+        if (bytes == null) return null;
+
+        ObjectInputStream ins =
+                //new ObjectInputStreamWithLoader(new FastByteArrayInputStream(bytes, bytes.length), classLoader);
+                new ObjectInputStream(new ByteArrayInputStream(bytes));
+        (T) ins.readObject();
+    }
+
+    /**
+     * @deprecated use Identifiers.makeRandomId(8)
+     */
+    @Deprecated
+    public static String newUid() { Identifiers.makeRandomId(8) }
+
+    public static Map setFieldsFromMap(Object target, Map fieldValues) {
+        Map unused = [:]
+        fieldValues.each {
+            //            println "looking for "+it.key+" in "+target+": "+target.metaClass.hasProperty(it.key)
+            target.hasProperty(it.key) ? target.(it.key) = it.value : unused << it
+        }
+        unused
+    }
+
+    /**
+     * Adds the given value to a collection in the map under the key.
+     * 
+     * A collection (as {@link LinkedHashMap}) will be created if necessary,
+     * synchronized on map for map access/change and set for addition there
+     *
+     * @return the updated set (instance, not copy)
+     * 
+     * @deprecated since 0.5; use {@link HashMultimap}, and {@link Multimaps#synchronizedSetMultimap(com.google.common.collect.SetMultimap)}
+     */
+    @Deprecated
+    public static <K,V> Set<V> addToMapOfSets(Map<K,Set<V>> map, K key, V valueInCollection) {
+        Set<V> coll;
+        synchronized (map) {
+            coll = map.get(key)
+            if (coll==null) {
+                coll = new LinkedHashSet<V>()
+                map.put(key, coll)
+            }
+            if (coll.isEmpty()) {
+                synchronized (coll) {
+                    coll.add(valueInCollection)
+                }
+                //if collection was empty then add to the collection while holding the map lock, to prevent removal
+                return coll
+            }
+        }
+        synchronized (coll) {
+            if (!coll.isEmpty()) {
+                coll.add(valueInCollection)
+                return coll;
+            }
+        }
+        //if was empty, recurse, because someone else might be removing the collection
+        return addToMapOfSets(map, key, valueInCollection);
+    }
+
+    /**
+     * as {@link #addToMapOfSets(Map, Object, Object)} but for {@link ArrayList}
+     * 
+     * @deprecated since 0.5; use {@link ArrayListMultimap}, and {@link Multimaps#synchronizedListMultimap(com.google.common.collect.ListMultimap)}
+     */
+    @Deprecated
+    public static <K,V> List<V> addToMapOfLists(Map<K,List<V>> map, K key, V valueInCollection) {
+        List<V> coll;
+        synchronized (map) {
+            coll = map.get(key)
+            if (coll==null) {
+                coll = new ArrayList<V>()
+                map.put(key, coll)
+            }
+            if (coll.isEmpty()) {
+                synchronized (coll) {
+                    coll.add(valueInCollection)
+                }
+                //if collection was empty then add to the collection while holding the map lock, to prevent removal
+                return coll
+            }
+        }
+        synchronized (coll) {
+            if (!coll.isEmpty()) {
+                coll.add(valueInCollection)
+                return coll;
+            }
+        }
+        //if was empty, recurse, because someone else might be removing the collection
+        return addToMapOfLists(map, key, valueInCollection);
+    }
+
+    /**
+     * Removes the given value from a collection in the map under the key.
+     *
+     * @return the updated set (instance, not copy)
+     * 
+     * @deprecated since 0.5; use {@link ArrayListMultimap} or {@link HashMultimap}, and {@link Multimaps#synchronizedListMultimap(com.google.common.collect.ListMultimap)} etc
+     */
+    @Deprecated
+    public static <K,V> boolean removeFromMapOfCollections(Map<K,? extends Collection<V>> map, K key, V valueInCollection) {
+        Collection<V> coll;
+        synchronized (map) {
+            coll = map.get(key)
+            if (coll==null) return false;
+        }
+        boolean result;
+        synchronized (coll) {
+            result = coll.remove(valueInCollection)
+        }
+        if (coll.isEmpty()) {
+            synchronized (map) {
+                synchronized (coll) {
+                    if (coll.isEmpty()) {
+                        //only remove from the map if no one is adding to the collection or to the map, and the collection is still in the map
+                        if (map.get(key)==coll) {
+                            map.remove(key)
+                        }
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Visits all fields of a given object, recursively.
+     *
+     * For collections, arrays, and maps it visits the items within, passing null for keys where it isn't a map.
+     */
+    public static void visitFields(Object o, FieldVisitor fv, Collection<Object> objectsToSkip=([] as Set)) {
+        if (o == null || objectsToSkip.contains(o)) return
+        objectsToSkip << o
+        if (o in String) return
+        if (o in Map) {
+            o.each { key, value ->
+                fv.visit(o, key.toString(), value)
+                visitFields(value, fv, objectsToSkip)
+            }
+        } else if ((o in Collection) || (o.getClass().isArray())) {
+            o.each {
+                entry ->
+                fv.visit(o, null, entry)
+                visitFields(entry, fv, objectsToSkip)
+            }
+        } else {
+            o.getClass().getDeclaredFields().each {
+                Field field ->
+                if ((field.getModifiers() & Modifier.STATIC) || field.isSynthetic()) return;  //skip static
+                field.setAccessible true
+                def v = field.get(o);
+                fv.visit(o, field.name, v)
+                visitFields(v, fv, objectsToSkip)
+            }
+        }
+    }
+
+    public interface FieldVisitor {
+        /** Invoked by visitFields; fieldName will be null for collections */
+        public void visit(Object parent, String fieldName, Object value)
+    }
+
+    /**
+     * Iterates through two collections simultaneously, passing both args to code.
+     * 
+     * <pre>
+     * a = ['a','b']; b=[1,2];
+     * assert ['a1','b2'] == forboth(a,b) { x,y -> x+y }
+     * </pre>
+     */
+    public static Collection forBoth(Collection l1, Collection l2, Closure code) {
+        def result=[]
+        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i]) ) }
+        result
+    }
+
+    public static Collection forBothWithIndex(Collection l1, Collection l2, Closure code) {
+        def result=[]
+        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i], i) ) }
+        result
+    }
+
+    public static Collection forBoth(Object[] l1, Object[] l2, Closure code) {
+        def result=[]
+        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i]) ) }
+        result
+    }
+
+    public static Collection forBothWithIndex(Object[] l1, Object[] l2, Closure code) {
+        def result=[]
+        l1.eachWithIndex { a, i -> result.add( code.call(a, l2[i], i) ) }
+        result
+    }
+
+    /** return value used to indicate that there is no such field */
+    public static final Object NO_SUCH_FIELD = new Object();
+
+    /**
+     * Default field getter.
+     *
+     * Delegates to {@code object[field]} (which will invoke a getter if one exists, in groovy),
+     * unless field starts with {@literal @} in which case it looks up the actual java field (bypassing getter).
+     * <p>
+     * Can be extended as needed when passed to {@link #equals(Object, Object, Class, String[])}
+     */
+    public static final Closure DEFAULT_FIELD_GETTER = { Object object, Object field ->
+        try {
+            if ((field in String) && field.startsWith("@")) {
+                return object.@"${field.substring(1)}"
+            }
+            return object[field]
+        } catch (Exception e) {
+            return NO_SUCH_FIELD
+        }
+    }
+
+    /**
+     * Checks equality of o1 and o2 with respect to the named fields, optionally enforcing a common superclass
+     * and using a custom field-getter.
+     *
+     * Other types can be supplied if they are supported by {@code object[field]} (what the {@link #DEFAULT_FIELD_GETTER} does)
+     * or if the {@literal optionalGetter} handles it. Note that {@code object[field]} causes invocation of {@code object.getAt(field)}
+     * (which can be provided on the object for non-strings - this is preferred to an optionalGetter, generally)
+     * looking for {@code object.getXxx()}, where field is a string {@literal xxx}, then {@code object.xxx}.
+     * <p>
+     * One exception is that field names which start with {@literal @} get the field directly according to {@link #DEFAULT_FIELD_GETTER},
+     * but use with care on private fields, as they must be on the object and not a superclass, and with groovy properties
+     * (formerly known as package-private, i.e. with no access modifiers) because they become private fields.
+     * <p>
+     * For example
+     * <pre>
+     * public class Foo {
+     *   Object bar;
+     *   public boolean equals(Object other) { LangaugeUtils.equals(this, other, Foo.class, ["bar"]); }
+     *   public int hashCode() { LangaugeUtils.hashCode(this, ["bar"]); }
+     * }
+     * </pre>
+     *
+     * @param o1 one object to compare
+     * @param o2 other object to compare
+     * @param optionalCommonSuperClass if supplied, returns false unless both objects are instances of the given type;
+     *     (if not supplied it effectively does duck typing, returning false if any field is not present)
+     * @param optionalGetter if supplied, a closure which takes (object, field) and returns the value of field on object;
+     *  should return static {@link #NO_SUCH_FIELD} if none found;
+     *  recommended to delegate to {@link #DEFAULT_FIELD_GETTER} at least for strings (or for anything)
+     * @param fields typically a list of strings being names of fields on the class to compare
+     * @return true if the two objects are equal in all indicated fields, and conform to the optionalCommonSuperClass if supplied
+     */
+    public static boolean equals(Object o1, Object o2, Class<?> optionalCommonSuperClass=null, Closure optionalGetter=null, Iterable<Object> fieldNames) {
+        if (o1==null) return o2==null;
+        if (o2==null) return false;
+        if (optionalCommonSuperClass) {
+            if (!(o1 in optionalCommonSuperClass) || !(o2 in optionalCommonSuperClass)) return false
+        }
+        Closure get = optionalGetter ?: DEFAULT_FIELD_GETTER
+        for (it in fieldNames) {
+            def v1 = get.call(o1, it)
+            if (v1==NO_SUCH_FIELD) return false
+            if (v1!=get.call(o2, it)) return false
+        }
+        return true
+    }
+
+    public static boolean equals(Object o1, Object o2, Class<?> optionalCommonSuperClass=null, Closure optionalGetter=null, Object[] fieldNames) {
+        return equals(o1, o2, optionalCommonSuperClass, optionalGetter, Arrays.asList(fieldNames) )
+    }
+
+    /**
+     * Generates a hashcode for an object.
+     * 
+     * Similar to {@link com.google.common.base.Objects#hashCode()} but taking field <em>names</em> and an optional getter,
+     * with the same rich groovy semantics as described in {@link #equals(Object, Object, Class)}.
+     */
+    public static int hashCode(Object o, Closure optionalGetter=null, Collection<Object> fieldNames) {
+        if (o==null) return 0;
+        Closure get = optionalGetter ?: DEFAULT_FIELD_GETTER
+        int result = 1;
+        for (it in fieldNames) {
+            def v1 = get.call(o, it)
+            if (v1==NO_SUCH_FIELD)
+                throw new NoSuchFieldError("Cannot access $it on "+o.getClass());
+            result = 31 * result + (it == null ? 0 : it.hashCode());
+        }
+        result
+    }
+
+    public static int hashCode(Object o, Closure optionalGetter=null, Object[] fieldNames) {
+        hashCode(o, optionalGetter, Arrays.asList(fieldNames))
+    }
+    
+    /** Default String representation is simplified name of class, together with selected fields. */
+    public static String toString(Object o, Closure optionalGetter=null, Collection<? extends CharSequence> fieldNames) {
+        if (o==null) return null;
+        Closure get = optionalGetter ?: DEFAULT_FIELD_GETTER
+        
+        StringBuilder result = new StringBuilder();
+        result.append(o.getClass().getSimpleName());
+        if (result.length() == 0) result.append(o.getClass().getName());
+        List<Object> fieldVals = fieldNames.collect {
+                Object v = get.call(o, it);
+                return (v != null) ? it+"="+v : null;
+        }
+        result.append("[").append(Joiner.on(",").skipNulls().join(fieldVals)).append("]");
+        return result.toString();
+    }
+}



Mime
View raw message