Top Description Methods
org.glassfish.pfl.basic.facet

public Interface FacetAccessor

Known Direct Implementers
org.glassfish.pfl.basic.facet.FacetAccessorDelegateImpl, org.glassfish.pfl.basic.facet.FacetAccessorImpl
Imports
java.lang.reflect.Field, .Method, java.util.Collection

Interface to access facets of an object. A facet is an instance of a particular class. It may be implemented in a variety of ways, including inheritance, delegation, or dynamic construction on demand.
Author
ken

Method Summary

Modifier and TypeMethod and Description
public <T> void
addFacet(T obj)

Add a facet to the object.

public <
The Type (as a Class) of the Facet.
T
>
T

Returns:

Instance of cls for this facet. Null if no such facet is available.
facet
(Class<T>
The class of the facet.
cls
)

Access the Facet of Class T from the object.

public Collection<Object>

Returns:

Collection of all facets.
facets
()

Return a list of all facets on this object.

public Object

Returns:

The value of the field
get
(Field
The field to access
field
)

Fetch the value of the field from whichever facet contains the field.

public Object

Returns:

restult of the invoke call.
invoke
(Method
The method to invoke.
method
,
Object...
Arguments to the method.
args
)

Invoke method on the appropriate facet of this object, that is, on the facet corresponding to method.getDeclaringClass.

public void
removeFacet(Class<?>
The class of the facet to remove.
cls
)

Remove the facet (if any) of the given type.

public void
set(Field field, Object value)

Method Detail

addFacetback to summary
public <T> void addFacet(T obj)

Add a facet to the object. The type T must not already be available as a facet.

facetback to summary
public <T> T facet(Class<T> cls)

Access the Facet of Class T from the object.

Parameters
<T>
The Type (as a Class) of the Facet.
cls:Class<T>

The class of the facet.

Returns:T

Instance of cls for this facet. Null if no such facet is available.

facetsback to summary
public Collection<Object> facets()

Return a list of all facets on this object.

Returns:Collection<Object>

Collection of all facets.

getback to summary
public Object get(Field field)

Fetch the value of the field from whichever facet contains the field. Read-only because that's all that the intended application needs.

Parameters
field:Field

The field to access

Returns:Object

The value of the field

invokeback to summary
public Object invoke(Method method, Object... args)

Invoke method on the appropriate facet of this object, that is, on the facet corresponding to method.getDeclaringClass.

Parameters
method:Method

The method to invoke.

args:Object[]

Arguments to the method.

Returns:Object

restult of the invoke call.

removeFacetback to summary
public void removeFacet(Class<?> cls)

Remove the facet (if any) of the given type.

Parameters
cls:Class<?>

The class of the facet to remove.

setback to summary
public void set(Field field, Object value)