Class ValueUtils
java.lang.Object
com.kingsrook.qqq.backend.core.utils.ValueUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
getFirstNonNull
(T... ts) Return the first argument that isn't null.static ZoneId
Get the (time) zoneId either for the current user session (based on session value UserTimezone or UserTimezoneOffsetMinutes), else the instance's defaultTimeZoneId string.static Instant
getStartOfMonthInZoneId
(String zoneId) static Instant
getStartOfTodayInZoneId
(String zoneId) static Instant
getStartOfYearInZoneId
(String zoneId) static BigDecimal
getValueAsBigDecimal
(Object value) Type-safely make a BigDecimal from any Object.static Boolean
getValueAsBoolean
(Object value) Returns null for null input; Returns the input object for Boolean-typed inputs.static byte[]
getValueAsByteArray
(Object value) static Serializable
getValueAsFieldType
(QFieldType type, Object value) static Instant
getValueAsInstant
(Object value) Type-safely make an Instant from any Object.static Integer
getValueAsInteger
(Object value) Type-safely make an Integer from any Object.static LocalDate
getValueAsLocalDate
(Object value) Type-safely make a LocalDate from any Object.static LocalDateTime
getValueAsLocalDateTime
(Object value) Type-safely make a LocalDateTime from any Object.static LocalTime
getValueAsLocalTime
(Object value) static Long
getValueAsLong
(Object value) Type-safely make an Long from any Object.static Map
getValueAsMap
(Serializable value) static String
getValueAsString
(Object value) Type-safely make a String from any Object.static <T extends Serializable>
TgetValueAsType
(Class<T> type, Object value) static QFieldType
inferQFieldTypeFromValue
(Serializable value, QFieldType defaultIfCannotInfer)
-
Constructor Details
-
ValueUtils
public ValueUtils()
-
-
Method Details
-
getValueAsString
-
getValueAsBoolean
-
getValueAsLong
Type-safely make an Long from any Object. null and empty-string inputs return null. We try to strip away commas and decimals (as long as they are exactly equal to the int value) We may throw if the input can't be converted to an integer.- Throws:
QValueException
-
getValueAsInteger
Type-safely make an Integer from any Object. null and empty-string inputs return null. We try to strip away commas and decimals (as long as they are exactly equal to the int value) We may throw if the input can't be converted to an integer.- Throws:
QValueException
-
getValueAsLocalDateTime
Type-safely make a LocalDateTime from any Object. null and empty-string inputs return null. We may throw if the input can't be converted to a LocalDateTime- Throws:
QValueException
-
getValueAsLocalDate
Type-safely make a LocalDate from any Object. null and empty-string inputs return null. We may throw if the input can't be converted to a LocalDate- Throws:
QValueException
-
getValueAsBigDecimal
Type-safely make a BigDecimal from any Object. null and empty-string inputs return null. We may throw if the input can't be converted to a BigDecimal- Throws:
QValueException
-
getValueAsInstant
-
getValueAsLocalTime
-
getValueAsByteArray
-
getValueAsType
-
getValueAsFieldType
-
getStartOfTodayInZoneId
-
getStartOfMonthInZoneId
-
getStartOfYearInZoneId
-
getFirstNonNull
Return the first argument that isn't null. If all were null, return null. -
getSessionOrInstanceZoneId
Get the (time) zoneId either for the current user session (based on session value UserTimezone or UserTimezoneOffsetMinutes), else the instance's defaultTimeZoneId string. -
inferQFieldTypeFromValue
public static QFieldType inferQFieldTypeFromValue(Serializable value, QFieldType defaultIfCannotInfer) -
getValueAsMap
-