| 
 | Brooklyn | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectbrooklyn.util.internal.LanguageUtils
@Deprecated @Beta class LanguageUtils
Useful Groovy utility methods.
| Nested Class Summary | |
|---|---|
| interface | LanguageUtils.FieldVisitor | 
| Field Summary | |
|---|---|
| static groovy.lang.Closure | DEFAULT_FIELD_GETTERDefault field getter. | 
| static java.lang.Object | NO_SUCH_FIELDreturn value used to indicate that there is no such field | 
| Method Summary | |
|---|---|
| static java.util.List | addToMapOfLists(java.util.Map map, java.lang.Object key, java.lang.Object valueInCollection)as addToMapOfSets(Map, Object, Object) but for java.util.ArrayList | 
| static java.util.Set | addToMapOfSets(java.util.Map map, java.lang.Object key, java.lang.Object valueInCollection)Adds the given value to a collection in the map under the key. | 
| static java.lang.Object | deserialize(byte[] bytes, java.lang.ClassLoader classLoader) | 
| static boolean | equals(java.lang.Object o1, java.lang.Object o2, java.lang.Class optionalCommonSuperClass = null, groovy.lang.Closure optionalGetter = null, java.lang.Iterable fieldNames)Checks equality of o1 and o2 with respect to the named fields, optionally enforcing a common superclass and using a custom field-getter. | 
| static boolean | equals(java.lang.Object o1, java.lang.Object o2, java.lang.Class optionalCommonSuperClass = null, groovy.lang.Closure optionalGetter = null, java.lang.Object[] fieldNames) | 
| static java.util.Collection | forBoth(java.util.Collection l1, java.util.Collection l2, groovy.lang.Closure code)Iterates through two collections simultaneously, passing both args to code. | 
| static java.util.Collection | forBoth(java.lang.Object[] l1, java.lang.Object[] l2, groovy.lang.Closure code) | 
| static java.util.Collection | forBothWithIndex(java.util.Collection l1, java.util.Collection l2, groovy.lang.Closure code) | 
| static java.util.Collection | forBothWithIndex(java.lang.Object[] l1, java.lang.Object[] l2, groovy.lang.Closure code) | 
| static java.lang.Object | getOptionalField(java.lang.String name, java.util.Map m, java.lang.Object defaultValue = null) | 
| static java.lang.Object | getPropertySafe(java.lang.Object target, java.lang.String name, java.lang.Object defaultValue = null) | 
| static java.lang.Object | getRequiredField(java.lang.String name, java.util.Map m) | 
| static int | hashCode(java.lang.Object o, groovy.lang.Closure optionalGetter = null, java.util.Collection fieldNames)Generates a hashcode for an object. | 
| static int | hashCode(java.lang.Object o, groovy.lang.Closure optionalGetter = null, java.lang.Object[] fieldNames) | 
| static java.lang.String | newUid()@deprecated use Identifiers.makeRandomId(8) | 
| static boolean | removeFromMapOfCollections(java.util.Map map, java.lang.Object key, java.lang.Object valueInCollection)Removes the given value from a collection in the map under the key. | 
| static byte[] | serialize(java.lang.Object orig) | 
| static java.util.Map | setFieldsFromMap(java.lang.Object target, java.util.Map fieldValues) | 
| static java.lang.String | toString(java.lang.Object o, groovy.lang.Closure optionalGetter = null, java.util.Collection fieldNames)Default String representation is simplified name of class, together with selected fields. | 
| static void | visitFields(java.lang.Object o, LanguageUtils.FieldVisitor fv, java.util.Collection objectsToSkip = ([] as Set)Visits all fields of a given object, recursively. | 
| Methods inherited from class java.lang.Object | |
|---|---|
| java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() | 
| Field Detail | 
|---|
public static final groovy.lang.Closure DEFAULT_FIELD_GETTER
Can be extended as needed when passed to equals(Object, Object, Class, String[])
public static final java.lang.Object NO_SUCH_FIELD
| Method Detail | 
|---|
@Deprecated static java.util.List addToMapOfLists(java.util.Map map, java.lang.Object key, java.lang.Object valueInCollection)
@Deprecated static java.util.Set addToMapOfSets(java.util.Map map, java.lang.Object key, java.lang.Object valueInCollection)
static java.lang.Object deserialize(byte[] bytes, java.lang.ClassLoader classLoader)
static boolean equals(java.lang.Object o1, java.lang.Object o2, java.lang.Class optionalCommonSuperClass = null, groovy.lang.Closure optionalGetter = null, java.lang.Iterable fieldNames)
One exception is that field names which start with {@literal
For example
 public class Foo {
   Object bar;
   public boolean equals(Object other) { LangaugeUtils.equals(this, other, Foo.class, ["bar"]); }
   public int hashCode() { LangaugeUtils.hashCode(this, ["bar"]); }
 }
 
     o1 -  one object to compareo2 -  other object to compareoptionalCommonSuperClass -  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)optionalGetter -  if supplied, a closure which takes (object, field) and returns the value of field on object;
  should return static NO_SUCH_FIELD if none found;
  recommended to delegate to DEFAULT_FIELD_GETTER at least for strings (or for anything)fields -  typically a list of strings being names of fields on the class to compare
static boolean equals(java.lang.Object o1, java.lang.Object o2, java.lang.Class optionalCommonSuperClass = null, groovy.lang.Closure optionalGetter = null, java.lang.Object[] fieldNames)
static java.util.Collection forBoth(java.util.Collection l1, java.util.Collection l2, groovy.lang.Closure code)
 a = ['a','b']; b=[1,2];
 assert ['a1','b2'] == forboth(a,b) { x,y -> x+y }
 
     
        
static java.util.Collection forBoth(java.lang.Object[] l1, java.lang.Object[] l2, groovy.lang.Closure code)
static java.util.Collection forBothWithIndex(java.util.Collection l1, java.util.Collection l2, groovy.lang.Closure code)
static java.util.Collection forBothWithIndex(java.lang.Object[] l1, java.lang.Object[] l2, groovy.lang.Closure code)
static java.lang.Object getOptionalField(java.lang.String name, java.util.Map m, java.lang.Object defaultValue = null)
static java.lang.Object getPropertySafe(java.lang.Object target, java.lang.String name, java.lang.Object defaultValue = null)
static java.lang.Object getRequiredField(java.lang.String name, java.util.Map m)
static int hashCode(java.lang.Object o, groovy.lang.Closure optionalGetter = null, java.util.Collection fieldNames)
static int hashCode(java.lang.Object o, groovy.lang.Closure optionalGetter = null, java.lang.Object[] fieldNames)
@Deprecated static java.lang.String newUid()
@Deprecated static boolean removeFromMapOfCollections(java.util.Map map, java.lang.Object key, java.lang.Object valueInCollection)
static byte[] serialize(java.lang.Object orig)
static java.util.Map setFieldsFromMap(java.lang.Object target, java.util.Map fieldValues)
static java.lang.String toString(java.lang.Object o, groovy.lang.Closure optionalGetter = null, java.util.Collection fieldNames)
static void visitFields(java.lang.Object o, LanguageUtils.FieldVisitor fv, java.util.Collection objectsToSkip = ([] as Set)
Brooklyn Multi-Cloud Application Management Platform 
 brooklyncentral.github.com. Apache License. © 2012.