Package org.glassfish.pfl.basic.facet
Class FacetAccessorImpl
- java.lang.Object
-
- org.glassfish.pfl.basic.facet.FacetAccessorImpl
-
- All Implemented Interfaces:
FacetAccessor
public class FacetAccessorImpl extends java.lang.Object implements FacetAccessor
-
-
Constructor Summary
Constructors Constructor Description FacetAccessorImpl(java.lang.Object delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
addFacet(T obj)
Add a facet to the object.<T> T
facet(java.lang.Class<T> cls)
Access the Facet of Class T from the object.java.util.Collection<java.lang.Object>
facets()
Return a list of all facets on this object.java.lang.Object
get(java.lang.reflect.Field field)
Fetch the value of the field from whichever facet contains the field.java.lang.Object
invoke(java.lang.reflect.Method method, java.lang.Object... args)
Invoke method on the appropriate facet of this object, that is, on the facet corresponding to method.getDeclaringClass.void
removeFacet(java.lang.Class<?> cls)
Remove the facet (if any) of the given type.void
set(java.lang.reflect.Field field, java.lang.Object value)
-
-
-
Method Detail
-
facet
public <T> T facet(java.lang.Class<T> cls)
Description copied from interface:FacetAccessor
Access the Facet of Class T from the object.- Specified by:
facet
in interfaceFacetAccessor
- Type Parameters:
T
- The Type (as a Class) of the Facet.- Parameters:
cls
- The class of the facet.- Returns:
- Instance of cls for this facet. Null if no such facet is available.
-
facets
public java.util.Collection<java.lang.Object> facets()
Description copied from interface:FacetAccessor
Return a list of all facets on this object.- Specified by:
facets
in interfaceFacetAccessor
- Returns:
- Collection of all facets.
-
addFacet
public <T> void addFacet(T obj)
Description copied from interface:FacetAccessor
Add a facet to the object. The type T must not already be available as a facet.- Specified by:
addFacet
in interfaceFacetAccessor
-
invoke
public java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object... args)
Description copied from interface:FacetAccessor
Invoke method on the appropriate facet of this object, that is, on the facet corresponding to method.getDeclaringClass.- Specified by:
invoke
in interfaceFacetAccessor
- Parameters:
method
- The method to invoke.args
- Arguments to the method.- Returns:
- restult of the invoke call.
-
get
public java.lang.Object get(java.lang.reflect.Field field)
Description copied from interface:FacetAccessor
Fetch the value of the field from whichever facet contains the field. Read-only because that's all that the intended application needs.- Specified by:
get
in interfaceFacetAccessor
- Parameters:
field
- The field to access- Returns:
- The value of the field
-
set
public void set(java.lang.reflect.Field field, java.lang.Object value)
- Specified by:
set
in interfaceFacetAccessor
-
removeFacet
public void removeFacet(java.lang.Class<?> cls)
Description copied from interface:FacetAccessor
Remove the facet (if any) of the given type.- Specified by:
removeFacet
in interfaceFacetAccessor
- Parameters:
cls
- The class of the facet to remove.
-
-