Package com.suse.salt.netapi.utils
Class ClientUtils
- java.lang.Object
-
- com.suse.salt.netapi.utils.ClientUtils
-
public class ClientUtils extends Object
Utilities forSaltClient
.
-
-
Constructor Summary
Constructors Constructor Description ClientUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
closeQuietly(InputStream stream)
Quietly close a given stream, suppressing exceptions.static ParameterizedType
parameterizedType(Type ownerType, Type rawType, Type... typeArguments)
Helper for constructing parameterized types.static String[]
splitFunction(String function)
Extract the module and function name from the function string based on '.' .static String
streamToString(InputStream inputStream)
Convert a givenInputStream
to aString
.static InputStream
stringToStream(String s)
Convert a givenString
to anInputStream
.
-
-
-
Method Detail
-
closeQuietly
public static void closeQuietly(InputStream stream)
Quietly close a given stream, suppressing exceptions.- Parameters:
stream
- Stream to close
-
stringToStream
public static InputStream stringToStream(String s)
Convert a givenString
to anInputStream
.- Parameters:
s
- a string- Returns:
- an input stream on the string
-
streamToString
public static String streamToString(InputStream inputStream)
Convert a givenInputStream
to aString
.- Parameters:
inputStream
- an input stream- Returns:
- the string in the input stream
-
parameterizedType
public static ParameterizedType parameterizedType(Type ownerType, Type rawType, Type... typeArguments)
Helper for constructing parameterized types.- Parameters:
ownerType
- the owner typerawType
- the raw typetypeArguments
- the type arguments- Returns:
- the parameterized type object
- See Also:
$Gson$Types.newParameterizedTypeWithOwner(java.lang.reflect.Type, java.lang.reflect.Type, java.lang.reflect.Type...)
-
splitFunction
public static String[] splitFunction(String function)
Extract the module and function name from the function string based on '.' . In case of e.g. "test.ping", this method will return String array {'test','ping'}- Parameters:
function
- string containing module and function name (e.g. "test.ping")- Returns:
- String array containing module name as 1st element and function name as 2nd
- Throws:
IllegalArgumentException
- if a given function string does not contain a '.'
-
-