Class DiffUtilFunction
java.lang.Object
io.higson.runtime.builtin.implementation.UtilFunction
io.higson.runtime.builtin.implementation.DiffUtilFunction
- All Implemented Interfaces:
ContextualUtilFunction
This class represents a utility function for performing various calculations based on the given arguments and the target object.
It extends the
UtilFunction class and implements the ContextualUtilFunction interface.-
Field Summary
FieldsFields inherited from class io.higson.runtime.builtin.implementation.UtilFunction
converter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall(HigsonContext ctx, Object[] args) Calculates the difference based on the given arguments and the target object.Methods inherited from class io.higson.runtime.builtin.implementation.UtilFunction
createHigsonRuntimeException, createHigsonRuntimeException, isValid, toTemporalAmountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.higson.runtime.builtin.implementation.ContextualUtilFunction
getContextPath
-
Field Details
-
CODE
- See Also:
-
INSTANCE
-
-
Constructor Details
-
DiffUtilFunction
public DiffUtilFunction()
-
-
Method Details
-
call
Calculates the difference based on the given arguments and the target object.- Specified by:
callin classUtilFunction- Parameters:
ctx- The HigsonContext object.args- The arguments passed to the method. The first argument should be the path to the target object in the context. The second argument should be the value to subtract from the target object. The third argument should be a string representation of the time token, if applicable.- Returns:
- The result of the difference calculation. If the target object and the diff value are both numbers, the method returns the subtraction of the two values. If the target object is a Date or LocalDateTime, and the diff value is a number, the method returns the difference in time based on the provided time token. If the target object is a String, the method returns the modified string after applying the difference operation. If none of the above conditions match, the method returns the target object as is.
- Throws:
HigsonRuntimeException- If the target object is a number and the diff value is not a number, an exception is thrown.
-