public class DefaultObjectBuilder<T> extends Object implements ObjectBuilder<T>, org.mule.runtime.api.lifecycle.Initialisable, ParameterValueResolver
ObjectBuilder which creates instances through a provided Class.| Modifier and Type | Field and Description |
|---|---|
protected Class<T> |
prototypeClass |
protected ReflectionCache |
reflectionCache |
protected Map<String,ValueResolver<? extends Object>> |
resolverByFieldName |
protected Map<FieldSetter,ValueResolver<Object>> |
resolvers |
| Constructor and Description |
|---|
DefaultObjectBuilder(Class<T> prototypeClass,
ReflectionCache reflectionCache)
Creates a new instance that will build instances of
prototypeClass. |
| Modifier and Type | Method and Description |
|---|---|
ObjectBuilder<T> |
addPropertyResolver(Field field,
ValueResolver<? extends Object> resolver)
Adds a property which value is to be obtained from a
ValueResolver |
ObjectBuilder<T> |
addPropertyResolver(String propertyName,
ValueResolver<? extends Object> resolver)
Adds a property which value is to be obtained from a
ValueResolver |
T |
build(ValueResolvingContext context)
Returns a new instance of the specified class.
|
Map<String,ValueResolver<? extends Object>> |
getParameters() |
Object |
getParameterValue(String parameterName) |
void |
initialise() |
boolean |
isDynamic()
Whether any of the registered
ValueResolvers are dynamic |
void |
setEncoding(String encoding) |
void |
setName(String name) |
protected final Map<FieldSetter,ValueResolver<Object>> resolvers
protected final Map<String,ValueResolver<? extends Object>> resolverByFieldName
protected ReflectionCache reflectionCache
public DefaultObjectBuilder(Class<T> prototypeClass, ReflectionCache reflectionCache)
prototypeClass.prototypeClass - a Class which needs to have a public defualt constructorpublic ObjectBuilder<T> addPropertyResolver(String propertyName, ValueResolver<? extends Object> resolver)
ValueResolverpropertyName - the name of the property in which the value is to be assignedresolver - a ValueResolver used to provide the actual value{@link - java.lang.IllegalArgumentException} if method or resolver are nullpublic ObjectBuilder<T> addPropertyResolver(Field field, ValueResolver<? extends Object> resolver)
ValueResolverfield - the property in which the value is to be assignedresolver - a ValueResolver used to provide the actual value{@link - java.lang.IllegalArgumentException} if method or resolver are nullpublic boolean isDynamic()
ValueResolvers are dynamicisDynamic in interface ObjectBuilder<T>true if at least one resolver is dynamic. false otherwisepublic T build(ValueResolvingContext context) throws org.mule.runtime.api.exception.MuleException
ObjectBuilderValueResolvingContext will be used to obtain a value from
each registered ValueResolverbuild in interface ObjectBuilder<T>context - a ValueResolvingContextorg.mule.runtime.api.exception.MuleExceptionpublic void setName(String name)
public void setEncoding(String encoding)
public void initialise()
throws org.mule.runtime.api.lifecycle.InitialisationException
initialise in interface org.mule.runtime.api.lifecycle.Initialisableorg.mule.runtime.api.lifecycle.InitialisationExceptionpublic Object getParameterValue(String parameterName) throws ValueResolvingException
getParameterValue in interface ParameterValueResolverValueResolvingException - if the resolution failspublic Map<String,ValueResolver<? extends Object>> getParameters()
getParameters in interface ParameterValueResolverValueResolvers as values.Copyright © 2003–2024 MuleSoft, Inc.. All rights reserved.