Class ValueUtils

java.lang.Object
com.kingsrook.qqq.backend.core.utils.ValueUtils

public class ValueUtils extends Object
Utilities work values - e.g., type-cast-like operations
  • Constructor Details

    • ValueUtils

      public ValueUtils()
  • Method Details

    • getValueAsString

      public static String getValueAsString(Object value)
      Type-safely make a String from any Object.
    • getValueAsBoolean

      public static Boolean getValueAsBoolean(Object value)
      Returns null for null input; Returns the input object for Boolean-typed inputs. Then, follows Boolean.parseBoolean, returning true iff value is a case-insensitive match for "true", for String.valueOf the input
    • getValueAsLong

      public static Long getValueAsLong(Object value) throws QValueException
      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

      public static Integer getValueAsInteger(Object value) throws QValueException
      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

      public static LocalDateTime getValueAsLocalDateTime(Object value) throws QValueException
      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

      public static LocalDate getValueAsLocalDate(Object value) throws QValueException
      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

      public static BigDecimal getValueAsBigDecimal(Object value) throws QValueException
      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

      public static Instant getValueAsInstant(Object value)
      Type-safely make an Instant from any Object. null and empty-string inputs return null. We may throw if the input can't be converted to a Instant
    • getValueAsLocalTime

      public static LocalTime getValueAsLocalTime(Object value)
    • getValueAsByteArray

      public static byte[] getValueAsByteArray(Object value)
    • getValueAsType

      public static <T extends Serializable> T getValueAsType(Class<T> type, Object value)
    • getValueAsFieldType

      public static Serializable getValueAsFieldType(QFieldType type, Object value)
    • getStartOfTodayInZoneId

      public static Instant getStartOfTodayInZoneId(String zoneId)
    • getStartOfMonthInZoneId

      public static Instant getStartOfMonthInZoneId(String zoneId)
    • getStartOfYearInZoneId

      public static Instant getStartOfYearInZoneId(String zoneId)
    • getFirstNonNull

      @SafeVarargs public static <T> T getFirstNonNull(T... ts)
      Return the first argument that isn't null. If all were null, return null.
    • getSessionOrInstanceZoneId

      public static ZoneId 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

      public static Map getValueAsMap(Serializable value)