public interface Faceted
asFacet(Class)
. Different implementations, or even different
instances, of a subject may support different facets.
Consult the subject's documentation to determine which facets are available
in each circumstance.
Faceted
class, it may be that some instances
support a particular facet while others do not, depending on the state of
the subject or the way it was constructed. In such cases
asFacet
should choose whether to return the facet
based on the subject's state.
Such classes should not extend the facet
interface (directly or indirectly), since that allows clients to bypass
asFacet
and simply downcast the subject to the facet,
causing problems for instances that can't support the facet.Facets
Modifier and Type | Method and Description |
---|---|
<T> T |
asFacet(Class<T> facetType)
Returns a facet of this subject if supported.
|
<T> T asFacet(Class<T> facetType)
T
- The requested facet type.facetType
- The type token of the requested facet type.Facets.asFacet(Class, Faceted)
,
Facets.assumeFacet(Class, Faceted)