Interface Faceted

All Known Subinterfaces:
_Private_IonManagedWriter, _Private_IonRawWriter, _Private_IonWriter, _Private_ListWriter, IonBinaryWriter, IonReader, IonTextReader, IonWriter, Span
All Known Implementing Classes:
_Private_IonBinaryWriterImpl, _Private_IonWriterBase

public interface Faceted
Provides access to optional extension interfaces of a subject instance. Users can request a facet of the subject by passing the desired type token to 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.

Design Notes

Given a concrete 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.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    asFacet(Class<T> facetType)
    Returns a facet of this subject if supported.
  • Method Details

    • asFacet

      <T> T asFacet(Class<T> facetType)
      Returns a facet of this subject if supported.
      Type Parameters:
      T - The requested facet type.
      Parameters:
      facetType - The type token of the requested facet type.
      Returns:
      An instance of T representing the facet of the subject, or null if the facet is not supported by the subject.
      See Also: