Class Utils
- java.lang.Object
-
- de.iip_ecosphere.platform.services.spring.Utils
-
public class Utils extends java.lang.ObjectSome utility functions. [public for testing]- Author:
- Holger Eichelberger, SSE
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddProperty(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String key, java.lang.Number value, java.lang.String deflt, java.util.function.Predicate<java.lang.Number> cond, java.util.function.Function<java.lang.Number,java.lang.String> formatter)Checks, formats and adds a deployer property.static voidaddPropertyIfPositiveToInt(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String key, java.lang.Number value, java.lang.String deflt)Checks, formats and adds an integer deployer property.static voidaddPropertyIfPositiveToMeBi(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String key, java.lang.Number value, java.lang.String deflt)Checks, formats and adds a long megabyte value as Mebibytes property.static java.lang.StringformatToMeBi(long number)Formatsnumberto Mebibytes (g/m only) without fractions and bytes as base unit.static java.lang.StringformatToMeBi(long number, int baseUnit)Formatsnumberto Mebibytes (g/m only) without fractions.
-
-
-
Method Detail
-
formatToMeBi
public static java.lang.String formatToMeBi(long number)
Formatsnumberto Mebibytes (g/m only) without fractions and bytes as base unit. For input outside the m/g range, the input is returned. Please be aware of number overflow for larger g values. [public for testing]- Parameters:
number- the number to be formatted- Returns:
- the formatted number
- See Also:
formatToMeBi(long, int)
-
formatToMeBi
public static java.lang.String formatToMeBi(long number, int baseUnit)Formatsnumberto Mebibytes (g/m only) without fractions. For input outside the m/g range (including t in terms of g), the input is returned. [public for testing]- Parameters:
number- the number to be formattedbaseUnit- 0 = bytes, 1 = kByte, 2 = mByte, 3 = gByte, ...- Returns:
- the formatted number
-
addPropertyIfPositiveToMeBi
public static void addPropertyIfPositiveToMeBi(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String key, java.lang.Number value, java.lang.String deflt)Checks, formats and adds a long megabyte value as Mebibytes property.- Parameters:
properties- the properties to be modified as a side effectkey- the key inPropertiesto modifyvalue- the number as value in megabytes to be addeddeflt- the formatted default ifnumberis not positive, may be null for no property at all- See Also:
formatToMeBi(long),addProperty(Map, String, Number, String, Predicate, Function)
-
addPropertyIfPositiveToInt
public static void addPropertyIfPositiveToInt(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String key, java.lang.Number value, java.lang.String deflt)Checks, formats and adds an integer deployer property.- Parameters:
properties- the properties to be modified as a side effectkey- the key inPropertiesto modifyvalue- the number as value to be addeddeflt- the formatted default ifnumberis not positive, may be null for no property at all- See Also:
addProperty(Map, String, Number, String, Predicate, Function)
-
addProperty
public static void addProperty(java.util.Map<java.lang.String,java.lang.String> properties, java.lang.String key, java.lang.Number value, java.lang.String deflt, java.util.function.Predicate<java.lang.Number> cond, java.util.function.Function<java.lang.Number,java.lang.String> formatter)Checks, formats and adds a deployer property.- Parameters:
properties- the properties to be modified as a side effectkey- the key inPropertiesto modifyvalue- the value to be addeddeflt- the formatted default ifnumberis not acceptable, may be null to add nothing as default valuecond- checksvalue, iftrueformat viaformatterand add askeytoproperties, else (ifdefltis not null, adddefltaskeytopropertiesformatter- the formatter fornumber
-
-