Class AbstractRuntimeObjectModel
- java.lang.Object
-
- org.apache.sling.scripting.sightly.render.AbstractRuntimeObjectModel
-
- All Implemented Interfaces:
RuntimeObjectModel
public abstract class AbstractRuntimeObjectModel extends java.lang.Object implements RuntimeObjectModel
Default abstract implementation ofRuntimeObjectModel
.
-
-
Constructor Summary
Constructors Constructor Description AbstractRuntimeObjectModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isCollection(java.lang.Object target)
Checks if an object is aCollection
or is backed by one.boolean
isDate(java.lang.Object target)
Checks if the provided object represents a date or calendar.boolean
isNumber(java.lang.Object target)
Checks if the provided object represents a number or not.boolean
isPrimitive(java.lang.Object obj)
Checks if the provided object represents a primitive data type or not.java.lang.Object
resolveProperty(java.lang.Object target, java.lang.Object property)
Resolve a property of a target object and return its value.boolean
toBoolean(java.lang.Object object)
Convert the given object to a boolean valuejava.util.Collection<java.lang.Object>
toCollection(java.lang.Object object)
Force the conversion of the object to a collectionjava.util.Date
toDate(java.lang.Object object)
Convert the given object to aDate
objectjava.time.Instant
toInstant(java.lang.Object object)
Convert the given object to anInstant
objectjava.util.Map
toMap(java.lang.Object object)
Force the conversion of the target object to a mapjava.lang.Number
toNumber(java.lang.Object object)
Coerce the object to a numeric valuejava.lang.String
toString(java.lang.Object target)
Convert the given object to a string.
-
-
-
Method Detail
-
isPrimitive
public boolean isPrimitive(java.lang.Object obj)
Description copied from interface:RuntimeObjectModel
Checks if the provided object represents a primitive data type or not.- Specified by:
isPrimitive
in interfaceRuntimeObjectModel
- Parameters:
obj
- the target object- Returns:
true
if thetarget
is a primitive,false
otherwise
-
isDate
public boolean isDate(java.lang.Object target)
Description copied from interface:RuntimeObjectModel
Checks if the provided object represents a date or calendar.- Specified by:
isDate
in interfaceRuntimeObjectModel
- Parameters:
target
- the target object- Returns:
true
if thetarget
is a date or calendar,false
otherwise
-
isNumber
public boolean isNumber(java.lang.Object target)
Description copied from interface:RuntimeObjectModel
Checks if the provided object represents a number or not.- Specified by:
isNumber
in interfaceRuntimeObjectModel
- Parameters:
target
- the target object- Returns:
true
if thetarget
is a number,false
otherwise
-
isCollection
public boolean isCollection(java.lang.Object target)
Description copied from interface:RuntimeObjectModel
Checks if an object is aCollection
or is backed by one.- Specified by:
isCollection
in interfaceRuntimeObjectModel
- Parameters:
target
- the target object- Returns:
true
if thetarget
is a collection or is backed by one,false
otherwise
-
resolveProperty
public java.lang.Object resolveProperty(java.lang.Object target, java.lang.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 interfaceRuntimeObjectModel
- Parameters:
target
- the target objectproperty
- the property to be resolved- Returns:
- the value of the property
-
toBoolean
public boolean toBoolean(java.lang.Object object)
Description copied from interface:RuntimeObjectModel
Convert the given object to a boolean value- Specified by:
toBoolean
in interfaceRuntimeObjectModel
- Parameters:
object
- the target object- Returns:
- the boolean representation of that object
-
toNumber
public java.lang.Number toNumber(java.lang.Object object)
Description copied from interface:RuntimeObjectModel
Coerce the object to a numeric value- Specified by:
toNumber
in interfaceRuntimeObjectModel
- Parameters:
object
- the target object- Returns:
- the numeric representation
-
toDate
public java.util.Date toDate(java.lang.Object object)
Description copied from interface:RuntimeObjectModel
Convert the given object to aDate
object- Specified by:
toDate
in interfaceRuntimeObjectModel
- Parameters:
object
- the target object- Returns:
- the date represented by the
object
-
toInstant
public java.time.Instant toInstant(java.lang.Object object)
Description copied from interface:RuntimeObjectModel
Convert the given object to anInstant
object- Specified by:
toInstant
in interfaceRuntimeObjectModel
- Parameters:
object
- the target object- Returns:
- the date represented by the
object
-
toString
public java.lang.String toString(java.lang.Object target)
Description copied from interface:RuntimeObjectModel
Convert the given object to a string.- Specified by:
toString
in interfaceRuntimeObjectModel
- Parameters:
target
- the target object- Returns:
- the string representation of the object
-
toCollection
public java.util.Collection<java.lang.Object> toCollection(java.lang.Object object)
Description copied from interface:RuntimeObjectModel
Force the conversion of the object to a collection- Specified by:
toCollection
in interfaceRuntimeObjectModel
- Parameters:
object
- the target object- Returns:
- the collection representation of the object
-
toMap
public java.util.Map toMap(java.lang.Object object)
Description copied from interface:RuntimeObjectModel
Force the conversion of the target object to a map- Specified by:
toMap
in interfaceRuntimeObjectModel
- Parameters:
object
- the target object- Returns:
- a map representation of the object. Default is an empty map
-
-