public class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
OS_NAME |
static String |
PATH_UNIX |
static String |
PATH_WINDOWS |
static String |
WINDOWS |
Modifier and Type | Method and Description |
---|---|
static <T> T |
checkNotNull(T ref,
String message) |
static void |
closeQuietly(Closeable... closeables)
Closes and flushes the specified
Closeable items. |
static void |
closeQuietly(Iterable<Closeable> closeables)
Closes and flushes the specified
Closeable items. |
static String |
coalesce(String... items) |
static String |
convertSystemPropertyNameToEnvVar(String systemPropertyName) |
static String |
filePath(URL path) |
static String |
getAnnotationValue(Class kubernetesResourceType,
Class annotationClass) |
static List<String> |
getCommandPlatformPrefix()
Returns prefixes needed to invoke specified command
in a subprocess.
|
static String |
getEnvVar(String envVarName,
String defaultValue) |
static String |
getPluralFromKind(String kind) |
static String |
getProperty(Map<String,Object> properties,
String propertyName) |
static String |
getProperty(Map<String,Object> properties,
String propertyName,
String defaultValue) |
static String |
getSystemPathVariable()
Get system PATH variable
|
static String |
getSystemPropertyOrEnvVar(String systemPropertyName) |
static boolean |
getSystemPropertyOrEnvVar(String systemPropertyName,
Boolean defaultValue) |
static int |
getSystemPropertyOrEnvVar(String systemPropertyName,
int defaultValue) |
static String |
getSystemPropertyOrEnvVar(String systemPropertyName,
String defaultValue) |
static String |
getSystemPropertyOrEnvVar(String systemPropertyName,
String envVarName,
String defaultValue) |
static String |
interpolateString(String templateInput,
Map<String,String> valuesMap)
Interpolates a String containing variable placeholders with the values provided in the valuesMap.
|
static <T> boolean |
isNotNull(T... refList) |
static boolean |
isNotNullOrEmpty(Map map) |
static boolean |
isNotNullOrEmpty(String str) |
static boolean |
isNotNullOrEmpty(String[] array) |
static boolean |
isNullOrEmpty(String str) |
static boolean |
isResourceNamespaced(Class kubernetesResourceType)
Reads @Namespaced annotation in resource class to check whether
resource is namespaced or not
|
static boolean |
isWindowsOperatingSystem()
Check whether platform is windows or not
|
static String |
join(Object[] array) |
static String |
join(Object[] array,
char separator) |
static String |
randomString(int length) |
static String |
randomString(String prefix,
int length) |
static String |
replaceAllWithoutRegex(String text,
String from,
String to)
Replaces all occurrences of the from text with to text without any regular expressions
|
static boolean |
shutdownExecutorService(ExecutorService executorService)
Closes the specified
ExecutorService . |
static String |
toUrlEncoded(String str)
Converts string to URL encoded string.
|
static boolean |
waitUntilReady(BlockingQueue<Object> queue,
long amount,
TimeUnit timeUnit)
Wait until an other thread signals the completion of a task.
|
public static final String WINDOWS
public static final String OS_NAME
public static final String PATH_WINDOWS
public static final String PATH_UNIX
public static <T> T checkNotNull(T ref, String message)
public static String getSystemPropertyOrEnvVar(String systemPropertyName, String envVarName, String defaultValue)
public static String convertSystemPropertyNameToEnvVar(String systemPropertyName)
public static String getSystemPropertyOrEnvVar(String systemPropertyName, String defaultValue)
public static boolean getSystemPropertyOrEnvVar(String systemPropertyName, Boolean defaultValue)
public static int getSystemPropertyOrEnvVar(String systemPropertyName, int defaultValue)
public static boolean waitUntilReady(BlockingQueue<Object> queue, long amount, TimeUnit timeUnit)
queue
- The communication channel.amount
- The amount of time to wait.timeUnit
- The time unit.public static boolean shutdownExecutorService(ExecutorService executorService)
ExecutorService
.executorService
- The executorService.public static void closeQuietly(Iterable<Closeable> closeables)
Closeable
items.public static void closeQuietly(Closeable... closeables)
Closeable
items.closeables
- An array of Closeable
items.public static String randomString(int length)
public static String replaceAllWithoutRegex(String text, String from, String to)
text
- text stringfrom
- from stringto
- to stringpublic static boolean isNullOrEmpty(String str)
public static boolean isNotNullOrEmpty(Map map)
public static boolean isNotNullOrEmpty(String str)
public static boolean isNotNullOrEmpty(String[] array)
public static <T> boolean isNotNull(T... refList)
public static String getProperty(Map<String,Object> properties, String propertyName, String defaultValue)
public static String toUrlEncoded(String str)
str
- Url as stringpublic static boolean isResourceNamespaced(Class kubernetesResourceType)
kubernetesResourceType
- class for resourcepublic static String getAnnotationValue(Class kubernetesResourceType, Class annotationClass)
public static String interpolateString(String templateInput, Map<String,String> valuesMap)
This method is intended to interpolate templates loaded from YAML and JSON files.
Placeholders are indicated by the dollar sign and curly braces (${VARIABLE_KEY}
).
Placeholders can also be indicated by the dollar sign and double curly braces (${{VARIABLE_KEY}}
),
when this notation is used, the resulting value will be unquoted (if applicable), expected values should be JSON
compatible.
valuesMap
- to interpolate in the StringtemplateInput
- raw input containing a String with placeholders ready to be interpolatedpublic static boolean isWindowsOperatingSystem()
public static String getSystemPathVariable()
Copyright © 2015–2020 Red Hat. All rights reserved.