Brooklyn

brooklyn.util.flags
[Java] Class FlagUtils

java.lang.Object
  brooklyn.util.flags.FlagUtils

public class FlagUtils

class to help transfer values passed as named arguments to other well-known variables/fields/objects; see the test case for example usage


Field Summary
static Logger log

 
Method Summary
static void checkRequiredFields(java.lang.Object o)

@throws an IllegalStateException if there are fields required (nullable=false) which are unset

static java.util.List getAllAssignableTypes(java.lang.Class base)

returns base, superclasses, then interfaces

static java.util.List getAllAssignableTypes(java.lang.Class base, groovy.lang.Closure filter)

static java.util.List getAllAssignableTypes(java.lang.Class base, Predicate filter)

static java.util.List getAllFields(java.lang.Class base, groovy.lang.Closure filter)

returns all fields on the given class, superclasses, and interfaces thereof, in that order of preference, (excluding fields on Object)

static java.util.List getAllFields(java.lang.Class base)

static java.util.List getAllFields(java.lang.Class base, Predicate filter)

static java.util.Map getAnnotatedFields(java.lang.Class type)

returns a map of all fields which are annotated 'SetFromFlag', along with the annotation

static java.lang.Object getDefaultValueForType(java.lang.Class t)

returns the default/inital value that is assigned to fields of the givien type; if the type is not primitive this value is null; for primitive types it is obvious but not AFAIK programmatically visible (e.g. 0 for int, false for boolean)

static java.lang.Object getField(java.lang.Object objectOfField, java.lang.reflect.Field f)

gets the value of the field.

static java.util.Map getFieldsWithValues(java.lang.Object o)

returns a map of all fields which are annotated 'SetFromFlag' with their current values; useful if you want to clone settings from one object

static java.util.List getLocalFields(java.util.List classes)

returns all fields explicitly declared on the given classes

static java.util.List getLocalFields(java.util.List classes, groovy.lang.Closure filter)

static java.util.List getLocalFields(java.util.List classes, Predicate filter)

static java.util.Map setConfigKeysFromFlags(java.util.Map flags, AbstractEntity entity)

static void setField(java.lang.Object objectOfField, java.lang.reflect.Field f, java.lang.Object value, SetFromFlag annotation)

sets the field to the value, after checking whether the given value can be set respecting the constraints of the annotation

static java.util.Map setFieldsFromFlags(java.util.Map flags, java.lang.Object o)

sets all fields (including private and static) on the given object and all supertypes, from the given flags map, returning just those flag-value pairs passed in which do not correspond to SetFromFlags fields

static java.util.Map setPublicFieldsFromFlags(java.util.Map flags, java.lang.Object o)

sets all public fields (local and inherited) on the given object from the given flags map, returning unknown elements

 
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

log

public static final Logger log


 
Method Detail

checkRequiredFields

public static void checkRequiredFields(java.lang.Object o)
throws:
an IllegalStateException if there are fields required (nullable=false) which are unset
throws:
wrapped IllegalAccessException


getAllAssignableTypes

public static java.util.List getAllAssignableTypes(java.lang.Class base)
returns base, superclasses, then interfaces


getAllAssignableTypes

public static java.util.List getAllAssignableTypes(java.lang.Class base, groovy.lang.Closure filter)


getAllAssignableTypes

public static java.util.List getAllAssignableTypes(java.lang.Class base, Predicate filter)


getAllFields

public static java.util.List getAllFields(java.lang.Class base, groovy.lang.Closure filter)
returns all fields on the given class, superclasses, and interfaces thereof, in that order of preference, (excluding fields on Object)


getAllFields

public static java.util.List getAllFields(java.lang.Class base)


getAllFields

public static java.util.List getAllFields(java.lang.Class base, Predicate filter)


getAnnotatedFields

public static java.util.Map getAnnotatedFields(java.lang.Class type)
returns a map of all fields which are annotated 'SetFromFlag', along with the annotation


getDefaultValueForType

public static java.lang.Object getDefaultValueForType(java.lang.Class t)
returns the default/inital value that is assigned to fields of the givien type; if the type is not primitive this value is null; for primitive types it is obvious but not AFAIK programmatically visible (e.g. 0 for int, false for boolean)


getField

public static java.lang.Object getField(java.lang.Object objectOfField, java.lang.reflect.Field f)
gets the value of the field.


getFieldsWithValues

public static java.util.Map getFieldsWithValues(java.lang.Object o)
returns a map of all fields which are annotated 'SetFromFlag' with their current values; useful if you want to clone settings from one object


getLocalFields

public static java.util.List getLocalFields(java.util.List classes)
returns all fields explicitly declared on the given classes


getLocalFields

public static java.util.List getLocalFields(java.util.List classes, groovy.lang.Closure filter)


getLocalFields

public static java.util.List getLocalFields(java.util.List classes, Predicate filter)


setConfigKeysFromFlags

public static java.util.Map setConfigKeysFromFlags(java.util.Map flags, AbstractEntity entity)


setField

public static void setField(java.lang.Object objectOfField, java.lang.reflect.Field f, java.lang.Object value, SetFromFlag annotation)
sets the field to the value, after checking whether the given value can be set respecting the constraints of the annotation


setFieldsFromFlags

public static java.util.Map setFieldsFromFlags(java.util.Map flags, java.lang.Object o)
sets all fields (including private and static) on the given object and all supertypes, from the given flags map, returning just those flag-value pairs passed in which do not correspond to SetFromFlags fields


setPublicFieldsFromFlags

public static java.util.Map setPublicFieldsFromFlags(java.util.Map flags, java.lang.Object o)
sets all public fields (local and inherited) on the given object from the given flags map, returning unknown elements


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.