Class Util

java.lang.Object
de.cxp.ocs.util.Util

public final class Util extends Object
  • Method Details

    • tryToParseAsNumber

      public static Optional<Number> tryToParseAsNumber(Object numVal)
    • collectObjects

      public static Object collectObjects(Object oldValue, Object newValue)
      If both values are not null, this method creates a flat collection of them. By default a HashSet is used as collection. If this is not wanted, pass another collection type as value. If one value is null, the other is returned and no collection is created. The inner types of the collection are not checked, so it's possible to merge different types into a collection. If a given value is an array, it will be transformed into a collection. Multidimensional arrays become a collection of array.
      Parameters:
      oldValue -
      newValue -
      Returns:
    • toStringCollection

      public static Collection<String> toStringCollection(Object value)
    • toNumberCollection

      public static Collection<Number> toNumberCollection(Object value)
    • asMap

      public static Map<String,String> asMap(String... keyValues)
    • isStringCollection

      public static boolean isStringCollection(Object value)
      Checks weather the passed value is a String Collection or not.
      Parameters:
      value - the value to check.
      Returns:
      true if the passed object is an string collection, false otherwise.
    • deduplicateAdjoinedTokens

      public static List<String> deduplicateAdjoinedTokens(String[] inputTokens)
    • ensureSameType

      public static Object ensureSameType(Object referenceObj, Object adjustableObj)
    • ensureNumberIsFloat

      public static Object ensureNumberIsFloat(Object x)
      Make sure, that if we have a number here, it will be represented by float. If it's not a number, the object will be returned as is.
      Returns:
    • isEmpty

      public static boolean isEmpty(Object value)