Interface Faceted

All Known Subinterfaces:
Entity, Player
All Known Implementing Classes:
AbstractPlayerActor

public interface Faceted
Indicates that an object can provide various "facets," which are specific distinct interfaces that can represent a portion of the object.

For example, an instance of an Entity may have a facet for accessing its inventory (if it contains an inventory) or a facet for accessing its health (if it has health).

Facets are referred to by their interface or abstract class and it is dependent on the implementation of the object specifying this interface to return the most applicable implementation. However, in many cases, such an implementation may not apply or it has not been implemented so a request for a facet may return null.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    getFacet(Class<? extends T> cls)
    Get the facet corresponding to the given class or interface.
  • Method Details

    • getFacet

      @Nullable <T> T getFacet(Class<? extends T> cls)
      Get the facet corresponding to the given class or interface.
      Type Parameters:
      T - the type
      Parameters:
      cls - the class or interface
      Returns:
      an implementation of the facet or null if one is unavailable