|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.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.lang.reflect.Field
|
findFieldForFlag(java.lang.String flagName, java.lang.Object o)
Finds the java.lang.reflect.Field on the given object annotated with the given name flag. |
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
|
getFieldsWithFlags(java.lang.Object o)
get all fields (including private and static) on the given object and all supertypes, that are annotated with SetFromFlags. |
static java.util.Map
|
getFieldsWithFlagsExcludingModifiers(java.lang.Object o, int excludingModifiers)
get all fields (including private and static) and their values on the given object and all supertypes, where the field is annotated with SetFromFlags. |
static java.util.Map
|
getFieldsWithFlagsWithModifiers(java.lang.Object o, int requiredModifiers)
get all fields with the given modifiers, and their values on the given object and all supertypes, where the field is annotated with SetFromFlags. |
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
|
setAllConfigKeys(java.util.Map flagsOrConfig, Configurable instance)
sets _all_ accessible _ConfigKey_ and HasConfigKey fields on the given object, using the indicated flags/config-bag |
static void
|
setAllConfigKeys(Configurable o, ConfigBag bag)
sets _all_ accessible _ConfigKey_ and HasConfigKey fields on the given object, using the indicated flags/config-bag |
static java.util.Map
|
setConfigKeysFromFlags(java.util.Map flags, Configurable instance)
@deprecated since 0.5.0 use setAllConfigKeys |
static void
|
setField(java.lang.Object objectOfField, java.lang.reflect.Field f, java.lang.Object value, SetFromFlag optionalAnnotation)
sets the field to the value, after checking whether the given value can be set respecting the constraints of the annotation |
static boolean
|
setFieldFromFlag(java.lang.Object o, java.lang.String flagName, java.lang.Object fieldVal)
Sets the field with the given flag (if it exists) to the given value. |
static java.util.Map
|
setFieldsFromFlags(java.util.Map flags, java.lang.Object o)
|
static void
|
setFieldsFromFlags(java.lang.Object o, ConfigBag configBag)
sets all fields (including private and static, local and inherited) annotated SetFromFlag on the given object, from the given flags map, returning just those flag-value pairs passed in which do not correspond to SetFromFlags fields annotated ConfigKey and HasConfigKey fields are _configured_ (and we assume the object in that case is Configurable); keys should be ConfigKey, HasConfigKey, or String; default values are also applied unless that is specified false on one of the variants of this method which takes such an argument |
static void
|
setFieldsFromFlags(java.lang.Object o, ConfigBag configBag, boolean setDefaultVals)
|
static void
|
setFieldsFromFlagsWithBag(java.lang.Object o, java.util.Map flags, ConfigBag configBag, boolean setDefaultVals)
as setFieldsFromFlags(Object o, ConfigBag), but specifying a subset of flags to use |
static java.util.Map
|
setPublicFieldsFromFlags(java.util.Map flags, java.lang.Object o)
|
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 Logger log
Method Detail |
---|
public static void checkRequiredFields(java.lang.Object o)
public static java.lang.reflect.Field findFieldForFlag(java.lang.String flagName, java.lang.Object o)
public static java.util.List getAllAssignableTypes(java.lang.Class base)
public static java.util.List getAllAssignableTypes(java.lang.Class base, groovy.lang.Closure filter)
public static java.util.List getAllAssignableTypes(java.lang.Class base, Predicate filter)
public static java.util.List getAllFields(java.lang.Class base, groovy.lang.Closure filter)
public static java.util.List getAllFields(java.lang.Class base)
public static java.util.List getAllFields(java.lang.Class base, Predicate filter)
public static java.util.Map getAnnotatedFields(java.lang.Class type)
public static java.lang.Object getDefaultValueForType(java.lang.Class t)
public static java.lang.Object getField(java.lang.Object objectOfField, java.lang.reflect.Field f)
public static java.util.Map getFieldsWithFlags(java.lang.Object o)
public static java.util.Map getFieldsWithFlagsExcludingModifiers(java.lang.Object o, int excludingModifiers)
public static java.util.Map getFieldsWithFlagsWithModifiers(java.lang.Object o, int requiredModifiers)
public static java.util.Map getFieldsWithValues(java.lang.Object o)
public static java.util.List getLocalFields(java.util.List classes)
public static java.util.List getLocalFields(java.util.List classes, groovy.lang.Closure filter)
public static java.util.List getLocalFields(java.util.List classes, Predicate filter)
public static java.util.Map setAllConfigKeys(java.util.Map flagsOrConfig, Configurable instance)
public static void setAllConfigKeys(Configurable o, ConfigBag bag)
public static java.util.Map setConfigKeysFromFlags(java.util.Map flags, Configurable instance)
ConfigKey> key = null; public static void setField(java.lang.Object objectOfField, java.lang.reflect.Field f, java.lang.Object value, SetFromFlag optionalAnnotation)
public static boolean setFieldFromFlag(java.lang.Object o, java.lang.String flagName, java.lang.Object fieldVal)
public static java.util.Map setFieldsFromFlags(java.util.Map flags, java.lang.Object o)
public static void setFieldsFromFlags(java.lang.Object o, ConfigBag configBag)
public static void setFieldsFromFlags(java.lang.Object o, ConfigBag configBag, boolean setDefaultVals)
public static void setFieldsFromFlagsWithBag(java.lang.Object o, java.util.Map flags, ConfigBag configBag, boolean setDefaultVals)
public static java.util.Map setPublicFieldsFromFlags(java.util.Map flags, java.lang.Object o)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.