Class Utils
java.lang.Object
de.iip_ecosphere.platform.services.spring.Utils
Some utility functions. [public for testing]
- Author:
- Holger Eichelberger, SSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddProperty(Map<String, String> properties, String key, Number value, String deflt, Predicate<Number> cond, Function<Number, String> formatter) Checks, formats and adds a deployer property.static voidChecks, formats and adds an integer deployer property.static voidChecks, formats and adds a long megabyte value as Mebibytes property.static StringformatToMeBi(long number) Formatsnumberto Mebibytes (g/m only) without fractions and bytes as base unit.static StringformatToMeBi(long number, int baseUnit) Formatsnumberto Mebibytes (g/m only) without fractions.static voidinitialize(org.springframework.context.ConfigurableApplicationContext applicationContext) Sets up an application context.static voidinitialize(org.springframework.context.ConfigurableApplicationContext applicationContext, Map<String, Object> overwrite) Sets up an application context.static voidinitialize(org.springframework.core.env.ConfigurableEnvironment env) Sets up a configurable environment.static voidinitialize(org.springframework.core.env.ConfigurableEnvironment env, Iterable<String> ignores) Sets up a configurable environment.static voidinitialize(org.springframework.core.env.ConfigurableEnvironment env, Map<String, Object> overwrite, Iterable<String> ignores) Sets up a configurable environment.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
formatToMeBi
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
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(Map<String, String> properties, String key, Number value, 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:
-
addPropertyIfPositiveToInt
public static void addPropertyIfPositiveToInt(Map<String, String> properties, String key, Number value, 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
public static void addProperty(Map<String, String> properties, String key, Number value, String deflt, Predicate<Number> cond, Function<Number, 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
-
initialize
public static void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext) Sets up an application context.- Parameters:
applicationContext- the application context
-
initialize
public static void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext, Map<String, Object> overwrite) Sets up an application context.- Parameters:
applicationContext- the application contextoverwrite- overwriting property values, may be null for none
-
initialize
public static void initialize(org.springframework.core.env.ConfigurableEnvironment env) Sets up a configurable environment.- Parameters:
env- the environment
-
initialize
public static void initialize(org.springframework.core.env.ConfigurableEnvironment env, Iterable<String> ignores) Sets up a configurable environment.- Parameters:
env- the environmentignores- the properties for not to return any value although defined or overridden, may be null or empty for none
-
initialize
public static void initialize(org.springframework.core.env.ConfigurableEnvironment env, Map<String, Object> overwrite, Iterable<String> ignores) Sets up a configurable environment.- Parameters:
env- the environmentoverwrite- overwriting property values, may be null for noneignores- the properties for not to return any value although defined or overridden, may be null or empty for none
-