OverloadedMethodsModel (FreeMarker 2.3.35 API)
Description: declaration: package: freemarker.ext.beans, class: OverloadedMethodsModel

Package freemarker.ext.beans

# Class OverloadedMethodsModel

java.lang.Object
freemarker.ext.beans.OverloadedMethodsModel

All Implemented Interfaces:
  `TemplateMethodModel`, `TemplateMethodModelEx`, `TemplateModel`, `TemplateSequenceModel`

public class OverloadedMethodsModel extends Object implements TemplateMethodModelEx, TemplateSequenceModel
Wraps a set of same-name overloaded methods behind `TemplateMethodModel` interface, like if it was a single method, chooses among them behind the scenes on call-time based on the argument values.

- ## Field Summary

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

  `NOTHING`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `exec​(List arguments)`
  Invokes the method, passing it the arguments from the list.
  `TemplateModel`
  `get​(int index)`
  Retrieves the i-th template model in this sequence.
  `int`
  `size()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### exec

    public Object exec​(List arguments) throws TemplateModelException
    Invokes the method, passing it the arguments from the list. The actual method to call from several overloaded methods will be chosen based on the classes of the arguments.
    Specified by:
      `exec` in interface `TemplateMethodModel`
    Specified by:
      `exec` in interface `TemplateMethodModelEx`
    Parameters:
      `arguments` - a `List` of `TemplateModel`-s, containing the arguments passed to the method. If the implementation absolutely wants to operate on POJOs, it can use the static utility methods in the `DeepUnwrap` class to easily obtain them. However, unwrapping is not always possible (or not perfectly), and isn't always efficient, so it's recommended to use the original `TemplateModel` value as much as possible.
    Returns:
      the return value of the method, or `null`. If the returned value does not implement `TemplateModel`, it will be automatically wrapped using the `environment's object wrapper`.
    Throws:
      `TemplateModelException` - if the method cannot be chosen unambiguously.

  - ### get

    public TemplateModel get​(int index) throws TemplateModelException
    Description copied from interface: `TemplateSequenceModel`
    Retrieves the i-th template model in this sequence.
    Specified by:
      `get` in interface `TemplateSequenceModel`
    Returns:
      the item at the specified index, or `null` if the index is out of bounds. Note that a `null` value is interpreted by FreeMarker as "variable does not exist", and accessing a missing variables is usually considered as an error in the FreeMarker Template Language, so the usage of a bad index will not remain hidden, unless the default value for that case was also specified in the template.
    Throws:
      `TemplateModelException`

  - ### size

    public int size() throws TemplateModelException
    Specified by:
      `size` in interface `TemplateSequenceModel`
    Returns:
      the number of items in the list.
    Throws:
      `TemplateModelException`