|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfun.yan.Components
public final class Components
This class provides implementations of some basic components as well as most of the commonly used combiniators for Component. A combinator is a function that will combine one or more Component objects and create a more complex Component object.
Codehaus.org.
| Constructor Summary | |
|---|---|
Components()
|
|
| Method Summary | ||
|---|---|---|
static
|
adapt(Creator<T> c)
To adapt a Creator object to a Component object. |
|
static
|
array(Component<T>... ccs)
Create a Component object that creates an array as instance. |
|
static
|
array(Component<T>[] ccs,
java.lang.Class<T> etype)
Create a Component object that creates an array as instance. |
|
static
|
autodetect(java.lang.Class<T> type,
java.lang.Object[] alternative_keys)
Create a Component object that delegates to another component in the current container. |
|
static Component |
autowired(Component c)
To create a Component that ignores all subsequent customizations to the parameters or properties. |
|
static
|
bean(java.lang.Class<T> type)
Create a Component object that uses Java Bean convention to create instance. |
|
static
|
bean(java.lang.Class<T> type,
java.util.Set props)
Create a Component object that uses Java Bean convention to create instance. |
|
static
|
bean(java.lang.Class<T> type,
java.lang.String[] props)
Create a Component object that uses Java Bean convention to create instance. |
|
static
|
bean(Component<T> cc)
Create a new Component object from a base Component object that calls Java Bean setters after the base Component creates the instance. |
|
static
|
bean(Component<T> cc,
java.util.Set props)
Create a new Component object from a base Component object that calls Java Bean setters after the base Component creates the instance. |
|
static
|
bean(Component<T> cc,
java.lang.String[] props)
Create a new Component object from a base Component object that calls Java Bean setters after the base Component creates the instance. |
|
static Component |
bindArgument(Component cc,
int k,
ParameterBinder binder)
Customize one argument of a component with a ParameterBinder object. |
|
static Component |
bindArguments(Component cc,
ParameterBinder binder)
Customize the arguments of a component with a ParameterBinder object. |
|
static Dependency |
bindArguments(Dependency dependency,
ParameterBinder binder)
Customize a Dependency object with a ParameterBinder object. |
|
static Component |
bindField(Component cc,
java.lang.reflect.Field fld)
Creates a Component that will read a certain field from the instance created by another Component. |
|
static Component |
bindField(Component cc,
java.lang.String name,
boolean suppress_security)
Creates a Component that will read a certain field from the instance created by another Component. |
|
static Component |
bindGetter(Component cc,
java.lang.String name)
Create a Component that will return a bean property of the instance created by another component. |
|
static Component |
bindGetter(Component cc,
java.lang.String name,
int ind)
Create a Component that will get an indexed property of the Java Bean instance created by another component. |
|
static Component |
bindMethod(Component cc,
java.lang.reflect.Method mtd)
Creates a Component that will call a certain method against the instance created by another Component. |
|
static Component |
bindMethod(Component cc,
java.lang.String name,
boolean suppress_security)
Creates a Component that will call a certain method against the instance created by another Component. |
|
static Component |
bindMethod(Component cc,
java.lang.String name,
java.lang.Class[] param_types,
boolean suppress_security)
Creates a Component that will call a certain method against the instance created by another Component. |
|
static Component |
bindMethod(Component cc,
java.lang.String name,
int param_count,
boolean suppress_security)
Creates a Component that will call a certain method against the instance created by another Component. |
|
static Component |
bindProperties(Component cc,
PropertyBinder binder)
Customize the properties of a component with a PropertyBinder object. |
|
static Dependency |
bindProperties(Dependency dependency,
PropertyBinder binder)
Customize a Dependency object with a PropertyBinder object. |
|
static Component |
bindProperty(Component cc,
java.lang.Object k,
PropertyBinder binder)
Customize the properties of a component with a PropertyBinder object. |
|
static
|
bindSetter(Component<T> cc,
java.lang.String name,
int ind)
Create a Component that will set an indexed property of the Java Bean instance created by another component. |
|
static Component |
bindSetter(Component cc,
java.lang.String name)
Create a Component that will set a bean property of the instance created by another component. |
|
static
|
cast(Component<?> cc,
java.lang.Class<T> type)
Customizes a Component object with a new component type. |
|
static
|
ctor(java.lang.Class<T> c)
Create a Component object that uses the constructor of a class to create instance of that class. |
|
static
|
ctor(java.lang.Class<T> c,
java.lang.Class[] param_types)
Create a Component that uses one constructor of a class to create instance of that class. |
|
static
|
factory(Creator<T> cc,
java.lang.String toString)
Create a Component that instantiates the Factory interface. |
|
static
|
factory(Creator cc,
java.lang.Class<F> factory_class,
java.lang.ClassLoader loader,
java.lang.String toString)
Create a Component that instantiates a factory interface. |
|
static
|
factory(Creator cc,
java.lang.Class<F> factory_class,
java.lang.String toString)
Create a Component that instantiates a factory interface. |
|
static Component |
field(java.lang.Class type,
java.lang.Object obj,
java.lang.String name)
Create a Component object that reads a field from a given object to create component instance. |
|
static Component |
field(java.lang.Object obj,
java.lang.String name)
Create a Component object that reads a field from a given object to create component instance. |
|
static Component |
fromArguments(Component cc,
java.lang.Object[] keys)
Redirects resolution of properties to arguments. |
|
static
|
fromLazy(LazyComponent<T> lcc,
java.lang.Object key)
Adapt a LazyComponent object to Component. |
|
static Component |
fromProperties(Component cc,
java.lang.Object[] keys)
Redirects resolution of arguments to properties. |
|
static
|
fun(Function<T> fun)
Create a Component object that uses a Function to create instance. |
|
static Component |
get(Component c,
java.lang.Object key)
To create a Component object that calls method "get" against the java.util.Map object instantiated by another Component. |
|
static Component |
getter(java.lang.Class type,
java.lang.Object obj,
java.lang.String prop)
Create a Component that calls a property getter of an object. |
|
static Component |
getter(java.lang.Object obj,
java.lang.String prop)
Create a Component that calls a property getter of an object. |
|
static
|
guard(Component<T> cc)
Decorate a Component object so that the new Component object guards against infinite dependency loop. |
|
static
|
hashmap(K[] keys,
Creator<T>[] creators)
Create a Component object that creates a java.util.LinkedHashMap object. |
|
static
|
hashset(Creator<T>... ccs)
Create a Component object that creates java.util.HashSet. |
|
static
|
incomplete(Component<T> cc)
By default, all components depended by a component will be verified when the component is verified. |
|
static Component |
indexed_getter(java.lang.Class type,
java.lang.Object obj,
java.lang.String prop,
int ind)
Create a Component that calls an indexed property getter of an object. |
|
static Component |
indexed_getter(java.lang.Object obj,
java.lang.String prop,
int ind)
Create a Component that calls an indexed property getter of an object. |
|
static
|
indexed_setter(java.lang.Class type,
T obj,
java.lang.String prop,
int ind)
Create a Component that calls an indexed property setter against an object. |
|
static
|
indexed_setter(T obj,
java.lang.String prop,
int ind)
Create a Component that calls an indexed property setter against an object. |
|
static ComponentBinder |
invokingGetter(java.lang.Class type,
java.lang.String name)
To create a ComponentBinder object that invokes a Java Bean getter against the bound object. |
|
static ComponentBinder |
invokingMethod(java.lang.Class type,
java.lang.String name,
boolean suppress_security)
Create a ComponentBinder object that invokes a method against the bound object. |
|
static ComponentBinder |
invokingMethod(java.lang.Class type,
java.lang.String name,
java.lang.Class[] param_types,
boolean suppress_security)
To create a ComponentBinder object that invokes a method against the bound object. |
|
static ComponentBinder |
invokingMethod(java.lang.Class type,
java.lang.String name,
int param_count,
boolean suppress_security)
Create a ComponentBinder object that invokes a method against the bound object. |
|
static
|
invokingSetter(java.lang.Class<T> type,
java.lang.String name)
Create a ComponentBinder object that will invoke a Java Bean setter against the bound object. |
|
static
|
label(Component<T> cc,
java.lang.Object lbl)
Label the frame for a Component so that whenever a YanException is thrown, the provided label will be populated in the resolution trace. |
|
static
|
list(Creator<T>... ccs)
Create a Component object that creates java.util.ArrayList. |
|
static
|
list(java.util.List<C> ccs)
Create a Component object that creates java.util.ArrayList. |
|
static
|
makeBean(Component<T> cc,
PropertiesInjector injector)
Create a Bean component that calls a PropertiesInjector to inject bean properties to the bean instance. |
|
static
|
makeBean(java.lang.String name,
Component<T> cc,
PropertiesInjector injector)
Create a Bean component that calls a PropertiesInjector to inject bean properties to the bean instance. |
|
static Component |
method(java.lang.Class type,
java.lang.Object obj,
java.lang.String name)
Create a Component object that invokes a method against a given object to create component instance. |
|
static Component |
method(java.lang.Class type,
java.lang.Object obj,
java.lang.String name,
java.lang.Class[] param_types)
Create a Component object that invokes a method against a given object to create component instance. |
|
static Component |
method(java.lang.Object obj,
java.lang.String name)
Create a Component object that invokes a method against a given object to create component instance. |
|
static Component |
method(java.lang.Object obj,
java.lang.String name,
java.lang.Class[] param_types)
Create a Component object that invokes a method against a given object to create component instance. |
|
static
|
mutate(Component<T> cc,
Mutation<T> m)
Customizes a Component object so that upon creation, the new Component object mutates the result component instance before it is returned. |
|
static
|
optionalParameter(Component<T> cc,
int k)
Creates a new Component object that makes a parameter optional. |
|
static
|
optionalParameters(Component<T> cc)
Make sure the parameters of a component are optional. |
|
static
|
optionalProperties(Component<T> cc)
Make sure the properties of a Java bean component are optional. |
|
static
|
optionalProperty(Component<T> cc,
java.lang.Object k)
Creates a new Component object that makes a property identified by a key optional. |
|
static Component |
proxy(Component cc)
Customizes a Component object so that the new Component object will return a dynamic proxy and hide the real component instance. |
|
static
|
proxy(Component<?> cc,
java.lang.Class<I> itf)
Customizes a Component object so that the new Component object will return a dynamic proxy and hide the real component instance. |
|
static Component |
proxy(Component cc,
java.lang.Class[] itfs)
Customizes a Component object so that the new Component object will return a dynamic proxy and hide the real component instance. |
|
static Component |
proxy(Component cc,
java.lang.Class[] itfs,
java.lang.ClassLoader loader)
Customizes a Component object so that the new Component object will return a dynamic proxy and hide the real component instance. |
|
static ComponentBinder |
readingField(java.lang.Class type,
java.lang.String name,
boolean suppress_security)
Create a ComponentBinder object that reads a field value from the bound object. |
|
static
|
repeat(Creator<T> cc,
int times)
Create a Component that repeatedly call another Component for certain amount of times. |
|
static Component |
returnState(Stateful st)
Create a Component object that returns the state of a Stateful object as its component instance. |
|
static Component |
returnType(Typeful t)
Create a Component object that returns the type of a Typeful object as its component instance. |
|
static Component |
returnVerification(Verifiable veri)
Create a Component object that verifies the Verifiable object and returns the result type as return value. |
|
static Component |
seal(Component cc)
Create a sealed component. |
|
static
|
setter(java.lang.Class type,
T obj,
java.lang.String prop)
Create a Component that calls a property setter against an object. |
|
static
|
setter(T obj,
java.lang.String prop)
Create a Component that calls a property setter against an object. |
|
static
|
singleton(Component<T> cc)
Create a new Component object that utilizes singleton pattern. |
|
static
|
singleton(Component<T> cc,
Pool<T> scope)
Create a new Component object that utilizes singleton pattern within the scope of the provided Pool object. |
|
static Component |
static_field(java.lang.Class c,
java.lang.String name)
Create a Component object that reads a static field to create instance. |
|
static Component |
static_method(java.lang.Class c,
java.lang.String name)
Create a Component object that invokes a static method to create instance. |
|
static Component |
static_method(java.lang.Class c,
java.lang.String name,
java.lang.Class[] param_types)
Create a Component object that invokes a static method to create instance. |
|
static
|
storeArray(Component<T[]> component_returning_array,
Creator<T>... creators)
|
|
static
|
storeList(Component<L> component_returning_list,
Creator<T>... creators)
Create a Component object that sequentially execute an array of components and collect the result into a java.util.List object. |
|
static
|
storeMap(Component<M> component_return_map,
K[] keys,
Creator<T>[] vals)
Create a Component that sequentially execute an array of Component object, and collect the results in a java.util.Map object. |
|
static
|
storeSet(Component<S> component_returning_set,
Creator<T>... creators)
Create a Component object that sequentially execute an array of components and collect the result into a java.util.Set object. |
|
static Component |
subscript(Component c,
int ind)
To create a Component that returns an element of the array/list instance returned from another Component object. |
|
static
|
subsume(Component<T> cc,
java.lang.Class<Super> type)
Customizes a Component object with a new component type. |
|
static
|
synchronizedComponent(Component<T> cc)
Create a Component that the "create()" method is put in a synchronized block to ensure thread safety. |
|
static Component<ComponentMap> |
thisContainer()
Create a Component object that returns the container object. |
|
static
|
useAll(java.lang.Class<T> type)
Create a Component object that creates a java.util.List. |
|
static
|
useAll(ComponentMap cmap,
java.lang.Class<T> type)
Create a Component object that creates a java.util.List. |
|
static
|
useArgument(Signature src,
int pos,
java.lang.Class<T> type)
Create a component that uses a particular argument value of the parent component as its instance. |
|
static Part |
useContainer(ComponentMap cmap)
Create a Part object that redirects the resolution of a typed parameter/property to another container. |
|
static Component |
useDefault()
Creates a Component that throws DefaultingException. |
|
static Component |
useKey(ComponentMap cmap,
java.lang.Object key)
Create a Component object that delegates to another component identified by a key in a container. |
|
static Component |
useKey(java.lang.Object key)
Create a Component object that delegates to another component identified by a key in the current container. |
|
static
|
useProperty(java.lang.Class component_type,
java.lang.Object key,
java.lang.Class<T> type)
Create a component that uses a particular property value of the parent component as its instance. |
|
static Component |
useState(ComponentMap cmap,
Predicate pred)
Create a Component object that creates a java.util.List. |
|
static Component |
useState(Predicate pred)
Create a Component object that creates a java.util.List. |
|
static
|
useType(java.lang.Class<T> type)
Create a Component object that delegates to another component in the current container. |
|
static
|
useType(ComponentMap cmap,
java.lang.Class<T> type)
Create a Component object that delegates to another component in a container. |
|
static Component<java.lang.Boolean> |
value(boolean val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Byte> |
value(byte val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Character> |
value(char val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Double> |
value(double val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Float> |
value(float val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Integer> |
value(int val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Long> |
value(long val)
Create a Component object that simply return a value upon instance creation. |
|
static Component<java.lang.Short> |
value(short val)
Create a Component object that simply return a value upon instance creation. |
|
static
|
value(T val)
Create a Component object that simply return a value upon instance creation. |
|
static
|
withArgument(Component<T> cc,
int k,
Part part)
Customizes the creation of one parameter of a Component object with a Part object. |
|
static Component |
withArgument(Component cc,
int k,
Creator factory)
Customizes the creation of one parameter of a Component object using a Creator object. |
|
static Component |
withArguments(Component cc,
Creator[] creators)
Customizes a Component's parameters with an array of Creator objects. |
|
static Component |
withArguments(Component cc,
Part part)
Customizes a Component with a Part object to create all its parameters. |
|
static
|
withDefaultArgument(Component<T> cc,
int k,
Creator v)
Create a Component object that will use an alternative Creator object when a certain parameter cannot be resolved or is passed in as default. |
|
static
|
withDefaultProperty(Component<T> cc,
java.lang.Object k,
Creator v)
Create a Component object that will use an alternative Creator object when a certain property cannot be resolved or is passed in as default. |
|
static Component |
withProperties(Component cc,
java.util.Map props)
Customizes a Component's properties with provided Creator objects stored in a java.util.Map object. |
|
static Component |
withProperties(Component cc,
Part part)
Customizes a Component object with a Part object to create all its property values. |
|
static Component |
withProperties(Component cc,
java.lang.String[] names,
Creator[] creators)
Customizes a Component's properties with the provided Creator objects. |
|
static
|
withProperty(Component<T> cc,
java.lang.Object k,
Creator factory)
Customizes the creation of one property value of a Component object with a Creator object. |
|
static
|
withProperty(Component<T> cc,
java.lang.Object k,
Part part)
Customizes the creation of one property value of a Component object with a Part object. |
|
static
|
withState(Component<T> cc,
java.lang.Object obj)
Customizes a Component object with the specified user state. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Components()
| Method Detail |
|---|
public static <T> Component<T> adapt(Creator<T> c)
c - the creator object.
public static <T> Component<T> fun(Function<T> fun)
fun - the Function object.
public static <T> Component<T> ctor(java.lang.Class<T> c)
throws java.lang.IllegalArgumentException
c - the class.
java.lang.IllegalArgumentException - if the class is not public or has no public constructor
or has more than one public constructor.
public static <T> Component<T> ctor(java.lang.Class<T> c,
java.lang.Class[] param_types)
throws java.lang.IllegalArgumentException
c - the class.param_types - the parameter types of the constructor to use.
null indicates the default constructor.
java.lang.IllegalArgumentException - if the type is not public or the public constructor cannot be found.
public static Component static_method(java.lang.Class c,
java.lang.String name)
throws java.lang.IllegalArgumentException
c - the class where the static method belongs.name - the static method name.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component static_method(java.lang.Class c,
java.lang.String name,
java.lang.Class[] param_types)
c - the class where the static method belongs.name - the static method name.param_types - the parameter types.
null indicates a parameter-less method.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component method(java.lang.Object obj,
java.lang.String name)
obj - the object to run the method against. It cannot be null.name - the method name.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component method(java.lang.Class type,
java.lang.Object obj,
java.lang.String name)
type - the Class object to look up method.
This parameter can be used when we only want to look up in
a super type rather than obj.getClass().obj - the object to run the method against.
It can be null if the method is static.name - the method name.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component method(java.lang.Object obj,
java.lang.String name,
java.lang.Class[] param_types)
obj - the object to run the method against.
It cannot be null.name - the method name.param_types - the parameter types.
null indicates a parameter-less method.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component method(java.lang.Class type,
java.lang.Object obj,
java.lang.String name,
java.lang.Class[] param_types)
type - the Class object to look up method.
This parameter can be used when we only want to look up in
a super type rather than obj.getClass().obj - the object to run the method against.
It can be null if the method is static.name - the method name.param_types - the parameter types.
null indicates a parameter-less method.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component static_field(java.lang.Class c,
java.lang.String name)
throws java.lang.IllegalArgumentException
c - the class where the static instance belongs.name - the static instance name.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component field(java.lang.Class type,
java.lang.Object obj,
java.lang.String name)
type - the Class object to look up field.
This parameter can be used when we only want to look up in
a super type rather than obj.getClass().obj - the object to read field from.
It can be null if the field is static.name - the field name.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component field(java.lang.Object obj,
java.lang.String name)
obj - the object to read the field from. It cannot be null.name - the field name.
java.lang.IllegalArgumentException - thrown if any of the following conditions is true:
public static Component getter(java.lang.Class type,
java.lang.Object obj,
java.lang.String prop)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonReadablePropertyException
type - the type to introspect.obj - the object to run the getter against.prop - the property name.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the property does not exist.
NonReadablePropertyException - if the property is not rreadable.
public static <T> Component<T> setter(java.lang.Class type,
T obj,
java.lang.String prop)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonWritablePropertyException
type - the type to introspect.obj - the object.prop - the property name.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the the property cannot be found.
NonWritablePropertyException - if the property is not writable.
public static Component indexed_getter(java.lang.Class type,
java.lang.Object obj,
java.lang.String prop,
int ind)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonReadablePropertyException
type - the type to introspect.obj - the object to run the getter against.prop - the property name.ind - the index.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the property does not exist.
NonReadablePropertyException - if the property is not rreadable or if the property is not indexed.
public static <T> Component<T> indexed_setter(java.lang.Class type,
T obj,
java.lang.String prop,
int ind)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonWritablePropertyException
type - the type to introspect.obj - the object.prop - the property name.ind - the index.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the the property cannot be found.
NonWritablePropertyException - if the property is not writable or not indexed.
public static Component getter(java.lang.Object obj,
java.lang.String prop)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonReadablePropertyException
obj - the object to run the getter against.prop - the property name.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the property does not exist.
NonReadablePropertyException - if the property is not rreadable.
public static <T> Component<T> setter(T obj,
java.lang.String prop)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonWritablePropertyException
obj - the object to run the setter against.prop - the property name.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the the property cannot be found.
NonWritablePropertyException - if the property is not writable.
public static Component indexed_getter(java.lang.Object obj,
java.lang.String prop,
int ind)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonReadablePropertyException
obj - the object to run the getter against.prop - the property name.ind - the index.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the property does not exist.
NonReadablePropertyException - if the property is not rreadable or if the property is not indexed.
public static <T> Component<T> indexed_setter(T obj,
java.lang.String prop,
int ind)
throws java.beans.IntrospectionException,
NoSuchPropertyException,
NonWritablePropertyException
obj - the object to run the setter against.prop - the property name.ind - the index.
java.beans.IntrospectionException - if introspection fails.
NoSuchPropertyException - if the the property cannot be found.
NonWritablePropertyException - if the property is not writable or not indexed.public static <T> Component<T> value(T val)
val - the value.
public static Component<java.lang.Double> value(double val)
val - the value.
public static Component<java.lang.Float> value(float val)
val - the value.
public static Component<java.lang.Long> value(long val)
val - the value.
public static Component<java.lang.Integer> value(int val)
val - the value.
public static Component<java.lang.Short> value(short val)
val - the value.
public static Component<java.lang.Byte> value(byte val)
val - the value.
public static Component<java.lang.Character> value(char val)
val - the value.
public static Component<java.lang.Boolean> value(boolean val)
val - the value.