Package de.cxp.ocs.util
Class Util
- java.lang.Object
-
- de.cxp.ocs.util.Util
-
public final class Util extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,String>asMap(String... keyValues)static ObjectcollectObjects(Object oldValue, Object newValue)If both values are not null, this method creates a flat collection of them.static List<String>deduplicateAdjoinedTokens(String[] inputTokens)static ObjectensureNumberIsFloat(Object x)Make sure, that if we have a number here, it will be represented by float.static ObjectensureSameType(Object referenceObj, Object adjustableObj)static booleanisEmpty(Object value)static booleanisStringCollection(Object value)Checks weather the passed value is aStringCollectionor not.static Collection<Number>toNumberCollection(Object value)static Collection<String>toStringCollection(Object value)static Optional<Number>tryToParseAsNumber(Object numVal)
-
-
-
Method Detail
-
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)
-
isStringCollection
public static boolean isStringCollection(Object value)
Checks weather the passed value is aStringCollectionor not.- Parameters:
value- the value to check.- Returns:
trueif the passed object is an string collection,falseotherwise.
-
deduplicateAdjoinedTokens
public static List<String> deduplicateAdjoinedTokens(String[] inputTokens)
-
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)
-
-