AdapterTemplateModel (FreeMarker 2.3.23 API)
Date: 2015-07-05

freemarker.template

## Interface AdapterTemplateModel

- All Superinterfaces:
    TemplateModel
  All Known Implementing Classes:
    ArrayModel, BeanModel, BooleanModel, CollectionModel, DateModel, DefaultArrayAdapter, DefaultIteratorAdapter, DefaultListAdapter, DefaultMapAdapter, DefaultNonListCollectionAdapter, EnumerationModel, IteratorModel, JythonHashModel, JythonModel, JythonNumberModel, JythonSequenceModel, MapModel, NodeModel, NumberModel, ResourceBundleModel, RhinoFunctionModel, RhinoScriptableModel, SimpleMapModel, StringModel

      public interface AdapterTemplateModel
      extends TemplateModel

  A `TemplateModel` that can be unwrapped and then it considers a provided desired (hint) class. This is useful when multiple languages has to communicate with each other through FreeMarker. For example, if we have a model that wraps a Jython object, then we have to unwrap that differently when we pass it to plain Java method and when we pass it to a Jython method.

  This is rarely implemented by applications. It is typically implemented by the model classes belonging to `ObjectWrapper`-s.

- - ### Field Summary

    - ### Fields inherited from interface freemarker.template.TemplateModel

      `NOTHING`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `getAdaptedObject(Class hint)` Retrieves the underlying object, or some other object semantically equivalent to its value narrowed by the class hint.

- - ### Method Detail

    - #### getAdaptedObject

          Object getAdaptedObject(Class hint)

      Retrieves the underlying object, or some other object semantically equivalent to its value narrowed by the class hint.
      Parameters:
        `hint` - the desired class of the returned value. An implementation should make reasonable effort to retrieve an object of the requested class, but if that is impossible, it must at least return the underlying object as-is. As a minimal requirement, an implementation must always return the exact underlying object when `hint.isInstance(underlyingObject)` holds. When called with `java.lang.Object.class`, it should return a generic Java object (i.e. if the model is wrapping a scripting language object that is further wrapping a Java object, the deepest underlying Java object should be returned).
      Returns:
        the underlying object, or its value accommodated for the hint class.