Package elf4j.engine.service.util
Class PropertiesUtils
- java.lang.Object
-
- elf4j.engine.service.util.PropertiesUtils
-
public class PropertiesUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IntegergetAsInteger(String name, @NonNull Properties properties)Takes only digits from the value to form a sequence, and tries to parse the sequence as anIntegerstatic Map<String,String>getChildProperties(String prefix, @NonNull Properties properties)static intgetIntOrDefault(String name, @NonNull Properties properties, int defaultValue)static List<Map<String,String>>getPropertiesGroupOfType(String type, @NonNull Properties properties)
-
-
-
Method Detail
-
getChildProperties
public static Map<String,String> getChildProperties(String prefix, @NonNull @NonNull Properties properties)
- Parameters:
prefix- key prefix to search forproperties- search source- Returns:
- all properties entries whose original keys start with the specified prefix. The prefix is removed from the keys of the returned entries.
-
getPropertiesGroupOfType
public static List<Map<String,String>> getPropertiesGroupOfType(String type, @NonNull @NonNull Properties properties)
- Parameters:
type- the properties value whose keys are each used as a parent key prefixproperties- search source- Returns:
- a group whose every member is a set of properties entries having a common key prefix of the specified type
-
getAsInteger
@Nullable public static Integer getAsInteger(String name, @NonNull @NonNull Properties properties)
Takes only digits from the value to form a sequence, and tries to parse the sequence as anInteger- Parameters:
name- full key in propertiesproperties- to look up in- Returns:
- Integer value of the specified name in the given properties, null if named entry missing or the corresponding value contains no digit
-
getIntOrDefault
public static int getIntOrDefault(String name, @NonNull @NonNull Properties properties, int defaultValue)
- Parameters:
name- full key in propertiesproperties- to look up indefaultValue- the default value to return if the delegate methodgetAsInteger(java.lang.String, java.util.Properties)returns null- Returns:
- result of the delegate method
getAsInteger(java.lang.String, java.util.Properties)or, if that is null, the specified defaultValue
-
-