Class AbstractRuntimeObjectModel
- java.lang.Object
-
- org.apache.sling.scripting.sightly.render.AbstractRuntimeObjectModel
-
- All Implemented Interfaces:
RuntimeObjectModel
public abstract class AbstractRuntimeObjectModel extends 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 protected ObjectgetProperty(Object target, Object propertyObj)booleanisCollection(Object target)Checks if an object is aCollectionor is backed by one.booleanisDate(Object target)Checks if the provided object represents a date or calendar.booleanisNumber(Object target)Checks if the provided object represents a number or not.booleanisPrimitive(Object obj)Checks if the provided object represents a primitive data type or not.ObjectresolveProperty(Object target, Object property)Resolve a property of a target object and return its value.booleantoBoolean(Object object)Convert the given object to a boolean valueCollection<Object>toCollection(Object object)Force the conversion of the object to a collectionDatetoDate(Object object)Convert the given object to aDateobjectInstanttoInstant(Object object)Convert the given object to anInstantobjectMaptoMap(Object object)Force the conversion of the target object to a mapNumbertoNumber(Object object)Coerce the object to a numeric valueStringtoString(Object target)Convert the given object to a string.
-
-
-
Method Detail
-
isPrimitive
public boolean isPrimitive(Object obj)
Description copied from interface:RuntimeObjectModelChecks if the provided object represents a primitive data type or not.- Specified by:
isPrimitivein interfaceRuntimeObjectModel- Parameters:
obj- the target object- Returns:
trueif thetargetis a primitive,falseotherwise
-
isDate
public boolean isDate(Object target)
Description copied from interface:RuntimeObjectModelChecks if the provided object represents a date or calendar.- Specified by:
isDatein interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
trueif thetargetis a date or calendar,falseotherwise
-
isNumber
public boolean isNumber(Object target)
Description copied from interface:RuntimeObjectModelChecks if the provided object represents a number or not.- Specified by:
isNumberin interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
trueif thetargetis a number,falseotherwise
-
isCollection
public boolean isCollection(Object target)
Description copied from interface:RuntimeObjectModelChecks if an object is aCollectionor is backed by one.- Specified by:
isCollectionin interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
trueif thetargetis a collection or is backed by one,falseotherwise
-
resolveProperty
public Object resolveProperty(Object target, Object property)
Description copied from interface:RuntimeObjectModelResolve a property of a target object and return its value. The property can be either an index or a name- Specified by:
resolvePropertyin interfaceRuntimeObjectModel- Parameters:
target- the target objectproperty- the property to be resolved- Returns:
- the value of the property
-
toBoolean
public boolean toBoolean(Object object)
Description copied from interface:RuntimeObjectModelConvert the given object to a boolean value- Specified by:
toBooleanin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the boolean representation of that object
-
toNumber
public Number toNumber(Object object)
Description copied from interface:RuntimeObjectModelCoerce the object to a numeric value- Specified by:
toNumberin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the numeric representation
-
toDate
public Date toDate(Object object)
Description copied from interface:RuntimeObjectModelConvert the given object to aDateobject- Specified by:
toDatein interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the date represented by the
object
-
toInstant
public Instant toInstant(Object object)
Description copied from interface:RuntimeObjectModelConvert the given object to anInstantobject- Specified by:
toInstantin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the date represented by the
object
-
toString
public String toString(Object target)
Description copied from interface:RuntimeObjectModelConvert the given object to a string.- Specified by:
toStringin interfaceRuntimeObjectModel- Parameters:
target- the target object- Returns:
- the string representation of the object
-
toCollection
public Collection<Object> toCollection(Object object)
Description copied from interface:RuntimeObjectModelForce the conversion of the object to a collection- Specified by:
toCollectionin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- the collection representation of the object
-
toMap
public Map toMap(Object object)
Description copied from interface:RuntimeObjectModelForce the conversion of the target object to a map- Specified by:
toMapin interfaceRuntimeObjectModel- Parameters:
object- the target object- Returns:
- a map representation of the object. Default is an empty map
-
-