Class Facets

java.lang.Object
com.amazon.ion.facet.Facets

public class Facets extends Object
Utility methods for working with facets.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    asFacet(Class<T> facetType, Faceted subject)
    Returns a facet of the given subject if supported, returning null otherwise.
    static <T> T
    asFacet(Class<T> facetType, Object subject)
    Returns a facet of the given subject if supported, returning null otherwise.
    static <T> T
    assumeFacet(Class<T> facetType, Faceted subject)
    Returns a facet of the given subject if supported, throwing an exception otherwise.
    static <T> T
    assumeFacet(Class<T> facetType, Object subject)
    Returns a facet of the given subject if supported, throwing an exception otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Facets

      public Facets()
  • Method Details

    • asFacet

      public static <T> T asFacet(Class<T> facetType, Faceted subject)
      Returns a facet of the given subject if supported, returning null otherwise.

      This does not attempt to cast the subject to the requested type, since the Faceted interface declares the intent to control the conversion.

      Returns:
      the requested facet, or null if subject is null or if subject doesn't support the requested facet type.
    • asFacet

      public static <T> T asFacet(Class<T> facetType, Object subject)
      Returns a facet of the given subject if supported, returning null otherwise.

      If the subject implements Faceted, then this conversion is delegated to Faceted.asFacet(Class). Otherwise, a simple cast of the subject is attempted.

      Returns:
      the requested facet, or null if subject is null or if subject doesn't support the requested facet type.
    • assumeFacet

      public static <T> T assumeFacet(Class<T> facetType, Faceted subject)
      Returns a facet of the given subject if supported, throwing an exception otherwise.

      This does not attempt to cast the subject to the requested type, since the Faceted interface declares the intent to control the conversion.

      Returns:
      not null.
      Throws:
      UnsupportedFacetException - if subject is null or if the subject doesn't support the requested facet type.
    • assumeFacet

      public static <T> T assumeFacet(Class<T> facetType, Object subject)
      Returns a facet of the given subject if supported, throwing an exception otherwise.

      If the subject implements Faceted, then this conversion is delegated to Faceted.asFacet(Class). Otherwise, a simple cast of the subject is attempted.

      Returns:
      not null.
      Throws:
      UnsupportedFacetException - if subject is null or if the subject doesn't support the requested facet type.