public class EnvUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DOCKER_HTTP_PORT |
static String |
MAVEN_PROPERTY_REGEXP |
static String |
PROPERTY_COMBINE_POLICY_SUFFIX |
Modifier and Type | Method and Description |
---|---|
static String |
convertTcpToHttpUrl(String connect) |
static String |
ensureRegistryHttpUrl(String registry) |
static List<String> |
extractFromPropertiesAsList(String prefix,
Properties properties)
Extract from given properties a list of string values.
|
static Map<String,String> |
extractFromPropertiesAsMap(String prefix,
Properties properties)
Extract part of given properties as a map.
|
static String |
extractLargerVersion(String versionA,
String versionB)
Compare to version strings and return the larger version strings.
|
static String |
extractMavenPropertyName(String propName)
Extract from a Maven property which is in the form ${name} the name.
|
static String |
firstRegistryOf(String... checkFirst)
Return the first non null registry given.
|
static String |
fixupPath(String path)
Fix path on Windows machines, i.e.
|
static String |
formatDurationTill(long start)
Calculate the duration between now and the given time
|
static String |
getEnvVarOrSystemProperty(String varName,
String defaultValue) |
static String |
getEnvVarOrSystemProperty(String envVarName,
String systemProperty,
String defaultValue) |
static boolean |
greaterOrEqualsVersion(String versionA,
String versionB)
Check whether the first given API version is larger or equals the second given version
|
static boolean |
isWindows() |
static Date |
loadTimestamp(File tsFile) |
static File |
prepareAbsoluteOutputDirPath(String outputDirectory,
String projectBaseDir,
String dir,
String path) |
static File |
prepareAbsoluteSourceDirPath(String sourceDirectory,
String projectBaseDir,
String path) |
static List<String> |
removeEmptyEntries(List<String> input)
Remove empty members of a list.
|
static List<String> |
splitAtCommasAndTrim(Iterable<String> input)
Split each element of an Iterable;<String;> at commas.
|
static List<String[]> |
splitOnLastColon(List<String> listToSplit)
Splits every element in the given list on the last colon in the name and returns a list with
two elements: The left part before the colon and the right part after the colon.
|
static String[] |
splitOnSpaceWithEscape(String toSplit) |
static void |
storeTimestamp(File tsFile,
Date buildDate) |
static String |
stringJoin(List list,
String separator)
Join a list of objects to a string with a given separator by calling Object.toString() on the elements.
|
public static final String MAVEN_PROPERTY_REGEXP
public static final String DOCKER_HTTP_PORT
public static final String PROPERTY_COMBINE_POLICY_SUFFIX
public static String extractLargerVersion(String versionA, String versionB)
If either version is null
, the other version is returned (which can be null as well)
versionA
- first version numberversionB
- second version numberpublic static boolean greaterOrEqualsVersion(String versionA, String versionB)
versionA
- first version to check againstversionB
- the second versionpublic static List<String[]> splitOnLastColon(List<String> listToSplit)
listToSplit
- list of strings to split@Nonnull public static List<String> removeEmptyEntries(@Nullable List<String> input)
input
- A list of String@Nonnull public static List<String> splitAtCommasAndTrim(Iterable<String> input)
input
- Iterable over strings.public static String stringJoin(List list, String separator)
list
- to joinseparator
- separator to usepublic static Map<String,String> extractFromPropertiesAsMap(String prefix, Properties properties)
NOTE: If key is "._combine" (PROPERTY_COMBINE_POLICY_SUFFIX
) it is ignored! This is reserved for combine policy tweaking.
prefix
- prefix which specifies the part which should be extracted as mapproperties
- properties to extract frompublic static List<String> extractFromPropertiesAsList(String prefix, Properties properties)
NOTE: If suffix/index is "._combine" (PROPERTY_COMBINE_POLICY_SUFFIX
) it is ignored!
This is reserved for combine policy tweaking.
prefix
- for selecting the properties from which the list should be extractedproperties
- properties from which to extract frompublic static String extractMavenPropertyName(String propName)
propName
- property name to extratpublic static String fixupPath(String path)
path
- path to fixpublic static String formatDurationTill(long start)
Taken mostly from http://stackoverflow.com/a/5062810/207604 . Kudos to @dblevins
start
- starting time (in milliseconds)public static String firstRegistryOf(String... checkFirst)
checkFirst
- list of registries to checkpublic static File prepareAbsoluteOutputDirPath(String outputDirectory, String projectBaseDir, String dir, String path)
public static File prepareAbsoluteSourceDirPath(String sourceDirectory, String projectBaseDir, String path)
public static void storeTimestamp(File tsFile, Date buildDate) throws IOException
IOException
public static Date loadTimestamp(File tsFile) throws IOException
IOException
public static boolean isWindows()
public static String getEnvVarOrSystemProperty(String varName, String defaultValue)
Copyright © 2021. All rights reserved.