Package io.littlehorse.sdk.common
Class LHVariableMapper
- java.lang.Object
-
- io.littlehorse.sdk.common.LHVariableMapper
-
public final class LHVariableMapper extends java.lang.ObjectUtility class to transform LittleHorse objects into Java objects
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tas(io.littlehorse.sdk.common.proto.VariableValue var, java.lang.Class<T> clazz)Converts a VariableValue to a deserialized Json object.static booleanasBoolean(io.littlehorse.sdk.common.proto.VariableValue var)Converts a VariableValue to a Boolean.static byte[]asBytes(io.littlehorse.sdk.common.proto.VariableValue var)Converts a VariableValue to bytes.static doubleasDouble(io.littlehorse.sdk.common.proto.VariableValue var)Converts a VariableValue to a Double.static intasInt(io.littlehorse.sdk.common.proto.VariableValue var)Converts a VariableValue to an Integer.static <T> java.util.Collection<T>asList(io.littlehorse.sdk.common.proto.VariableValue var, java.lang.Class<T> clazz)Converts a VariableValue to a Collection of deserialized Json objects.static longasLong(io.littlehorse.sdk.common.proto.VariableValue var)Converts a VariableValue to a Long.static java.lang.StringasString(io.littlehorse.sdk.common.proto.VariableValue var)Converts a VariableValue to String.
-
-
-
Method Detail
-
asInt
public static int asInt(io.littlehorse.sdk.common.proto.VariableValue var)
Converts a VariableValue to an Integer. This method enforces that the VariableValue contains an integer value.- Parameters:
var- The VariableValue to convert to an integer.- Returns:
- The integer value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain an integer.
-
asLong
public static long asLong(io.littlehorse.sdk.common.proto.VariableValue var)
Converts a VariableValue to a Long. This method enforces that the VariableValue contains a long value.- Parameters:
var- The VariableValue to convert to a long.- Returns:
- The long value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain a long.
-
asDouble
public static double asDouble(io.littlehorse.sdk.common.proto.VariableValue var)
Converts a VariableValue to a Double. This method enforces that the VariableValue contains a double value.- Parameters:
var- The VariableValue to convert to a double.- Returns:
- The double value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain a double.
-
asBoolean
public static boolean asBoolean(io.littlehorse.sdk.common.proto.VariableValue var)
Converts a VariableValue to a Boolean. This method enforces that the VariableValue contains a boolean value.- Parameters:
var- The VariableValue to convert to a boolean.- Returns:
- The boolean value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain a boolean.
-
asBytes
public static byte[] asBytes(io.littlehorse.sdk.common.proto.VariableValue var)
Converts a VariableValue to bytes. This method enforces that the VariableValue contains bytes in the value.- Parameters:
var- The VariableValue to convert to a bytes.- Returns:
- The bytes value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain bytes.
-
asString
public static java.lang.String asString(io.littlehorse.sdk.common.proto.VariableValue var)
Converts a VariableValue to String. This method enforces that the VariableValue contains a String value.- Parameters:
var- The VariableValue to convert to a bytes.- Returns:
- The bytes value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain bytes.
-
as
public static <T> T as(io.littlehorse.sdk.common.proto.VariableValue var, java.lang.Class<T> clazz)Converts a VariableValue to a deserialized Json object. This method enforces that the VariableValue contains a Json object value.- Parameters:
var- The VariableValue to convert to a Json object.- Returns:
- The deserialized Json object value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain Json object.
-
asList
public static <T> java.util.Collection<T> asList(io.littlehorse.sdk.common.proto.VariableValue var, java.lang.Class<T> clazz)Converts a VariableValue to a Collection of deserialized Json objects. This method enforces that the VariableValue contains a Json array value.- Parameters:
var- The VariableValue to convert.- Returns:
- The collection of deserialized Json objects value represented by the VariableValue.
- Throws:
java.lang.IllegalArgumentException- If the VariableValue does not contain Json array.
-
-