Class ClientUtils


  • public class ClientUtils
    extends java.lang.Object
    Utilities for SaltClient.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeQuietly​(java.io.InputStream stream)
      Quietly close a given stream, suppressing exceptions.
      static java.lang.reflect.ParameterizedType parameterizedType​(java.lang.reflect.Type ownerType, java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
      Helper for constructing parameterized types.
      static java.lang.String[] splitFunction​(java.lang.String function)
      Extract the module and function name from the function string based on '.' .
      static java.lang.String streamToString​(java.io.InputStream inputStream)
      Convert a given InputStream to a String.
      static java.io.InputStream stringToStream​(java.lang.String s)
      Convert a given String to an InputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClientUtils

        public ClientUtils()
    • Method Detail

      • closeQuietly

        public static void closeQuietly​(java.io.InputStream stream)
        Quietly close a given stream, suppressing exceptions.
        Parameters:
        stream - Stream to close
      • stringToStream

        public static java.io.InputStream stringToStream​(java.lang.String s)
        Convert a given String to an InputStream.
        Parameters:
        s - a string
        Returns:
        an input stream on the string
      • streamToString

        public static java.lang.String streamToString​(java.io.InputStream inputStream)
        Convert a given InputStream to a String.
        Parameters:
        inputStream - an input stream
        Returns:
        the string in the input stream
      • parameterizedType

        public static java.lang.reflect.ParameterizedType parameterizedType​(java.lang.reflect.Type ownerType,
                                                                            java.lang.reflect.Type rawType,
                                                                            java.lang.reflect.Type... typeArguments)
        Helper for constructing parameterized types.
        Parameters:
        ownerType - the owner type
        rawType - the raw type
        typeArguments - 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 java.lang.String[] splitFunction​(java.lang.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:
        java.lang.IllegalArgumentException - if a given function string does not contain a '.'