Class AbstractRuntimeObjectModel

java.lang.Object
org.apache.sling.scripting.sightly.render.AbstractRuntimeObjectModel
All Implemented Interfaces:
RuntimeObjectModel
Direct Known Subclasses:
SlingRuntimeObjectModel

public abstract class AbstractRuntimeObjectModel extends Object implements RuntimeObjectModel
Default abstract implementation of RuntimeObjectModel.
  • Constructor Details

    • AbstractRuntimeObjectModel

      public AbstractRuntimeObjectModel()
  • Method Details

    • isPrimitive

      public boolean isPrimitive(Object obj)
      Description copied from interface: RuntimeObjectModel
      Checks if the provided object represents a primitive data type or not.
      Specified by:
      isPrimitive in interface RuntimeObjectModel
      Parameters:
      obj - the target object
      Returns:
      true if the target is a primitive, false otherwise
    • isDate

      public boolean isDate(Object target)
      Description copied from interface: RuntimeObjectModel
      Checks if the provided object represents a date or calendar.
      Specified by:
      isDate in interface RuntimeObjectModel
      Parameters:
      target - the target object
      Returns:
      true if the target is a date or calendar, false otherwise
    • isNumber

      public boolean isNumber(Object target)
      Description copied from interface: RuntimeObjectModel
      Checks if the provided object represents a number or not.
      Specified by:
      isNumber in interface RuntimeObjectModel
      Parameters:
      target - the target object
      Returns:
      true if the target is a number, false otherwise
    • isCollection

      public boolean isCollection(Object target)
      Description copied from interface: RuntimeObjectModel
      Checks if an object is a Collection or is backed by one.
      Specified by:
      isCollection in interface RuntimeObjectModel
      Parameters:
      target - the target object
      Returns:
      true if the target is a collection or is backed by one, false otherwise
    • resolveProperty

      public Object resolveProperty(Object target, Object property)
      Description copied from interface: RuntimeObjectModel
      Resolve a property of a target object and return its value. The property can be either an index or a name
      Specified by:
      resolveProperty in interface RuntimeObjectModel
      Parameters:
      target - the target object
      property - the property to be resolved
      Returns:
      the value of the property
    • toBoolean

      public boolean toBoolean(Object object)
      Description copied from interface: RuntimeObjectModel
      Convert the given object to a boolean value
      Specified by:
      toBoolean in interface RuntimeObjectModel
      Parameters:
      object - the target object
      Returns:
      the boolean representation of that object
    • toNumber

      public Number toNumber(Object object)
      Description copied from interface: RuntimeObjectModel
      Coerce the object to a numeric value
      Specified by:
      toNumber in interface RuntimeObjectModel
      Parameters:
      object - the target object
      Returns:
      the numeric representation
    • toDate

      public Date toDate(Object object)
      Description copied from interface: RuntimeObjectModel
      Convert the given object to a Date object
      Specified by:
      toDate in interface RuntimeObjectModel
      Parameters:
      object - the target object
      Returns:
      the date represented by the object
    • toInstant

      public Instant toInstant(Object object)
      Description copied from interface: RuntimeObjectModel
      Convert the given object to an Instant object
      Specified by:
      toInstant in interface RuntimeObjectModel
      Parameters:
      object - the target object
      Returns:
      the date represented by the object
    • toString

      public String toString(Object target)
      Description copied from interface: RuntimeObjectModel
      Convert the given object to a string.
      Specified by:
      toString in interface RuntimeObjectModel
      Parameters:
      target - the target object
      Returns:
      the string representation of the object
    • toCollection

      public Collection<Object> toCollection(Object object)
      Description copied from interface: RuntimeObjectModel
      Force the conversion of the object to a collection
      Specified by:
      toCollection in interface RuntimeObjectModel
      Parameters:
      object - the target object
      Returns:
      the collection representation of the object
    • toMap

      public Map toMap(Object object)
      Description copied from interface: RuntimeObjectModel
      Force the conversion of the target object to a map
      Specified by:
      toMap in interface RuntimeObjectModel
      Parameters:
      object - the target object
      Returns:
      a map representation of the object. Default is an empty map
    • getProperty

      protected Object getProperty(Object target, Object propertyObj)