Class GenericObjectModel

All Implemented Interfaces:
WrapperTemplateModel, AdapterTemplateModel, MethodCallAwareTemplateHashModel, TemplateHashModel, TemplateHashModelEx, TemplateModel, TemplateModelWithAPISupport, TemplateScalarModel

public class GenericObjectModel extends StringModel implements MethodCallAwareTemplateHashModel
This is used for wrapping objects that has no special treatment (unlike Map-s, Collection-s, Number-s, Boolean-s, and some more, which have), hence they are just "generic" Java objects. Users usually just want to call the public Java methods on such objects. These objects can also be used as string values in templates, and that value is provided by the Object.toString() method of the wrapped object.

This extends StringModel for backward compatibility, as now BeansWrapper returns instances of GenericObjectModel instead of StringModel-s, but user code may have insteanceof StringModel, or casing to StringModel. StringModel served the same purpose as this class, but didn't implement MethodCallAwareTemplateHashModel.

Since:
2.3.33
  • Constructor Details

    • GenericObjectModel

      public GenericObjectModel(Object object, BeansWrapper wrapper)
      Creates a new model that wraps the specified object with BeanModel + scalar functionality.
      Parameters:
      object - the object to wrap into a model.
      wrapper - the BeansWrapper associated with this model. Every model has to have an associated BeansWrapper instance. The model gains many attributes from its wrapper, including the caching behavior, method exposure level, method-over-item shadowing policy etc.
  • Method Details