Package org.glassfish.pfl.basic.facet
Interface FacetAccessor
-
- All Known Implementing Classes:
FacetAccessorDelegateImpl,FacetAccessorImpl
public interface FacetAccessorInterface 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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> voidaddFacet(T obj)Add a facet to the object.<T> Tfacet(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.Objectget(java.lang.reflect.Field field)Fetch the value of the field from whichever facet contains the field.java.lang.Objectinvoke(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.voidremoveFacet(java.lang.Class<?> cls)Remove the facet (if any) of the given type.voidset(java.lang.reflect.Field field, java.lang.Object value)
-
-
-
Method Detail
-
facet
<T> T facet(java.lang.Class<T> cls)
Access the Facet of Class T from the object.- 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.
-
addFacet
<T> void addFacet(T obj)
Add a facet to the object. The type T must not already be available as a facet.- Type Parameters:
T-- Parameters:
obj-
-
removeFacet
void removeFacet(java.lang.Class<?> cls)
Remove the facet (if any) of the given type.- Parameters:
cls- The class of the facet to remove.
-
facets
java.util.Collection<java.lang.Object> facets()
Return a list of all facets on this object.- Returns:
- Collection of all facets.
-
invoke
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.- Parameters:
method- The method to invoke.args- Arguments to the method.- Returns:
- restult of the invoke call.
-
get
java.lang.Object get(java.lang.reflect.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- The field to access- Returns:
- The value of the field
-
set
void set(java.lang.reflect.Field field, java.lang.Object value)
-
-