Class Formatter


  • @Generated("de.xima.openapi.codegen.java_jaxrs.XimaJavaJaxrsGenerator")
    public final class Formatter
    extends Object
    Helper methods for web related tasks such as URL encoding etc.
    • Method Detail

      • parameterToString

        public String parameterToString​(Object param)
        Format the given parameter object into string.
        Parameters:
        param - an object to format
        Returns:
        the String version of the object
      • parameterToPairs

        public List<Pair> parameterToPairs​(String collectionFormat,
                                           String name,
                                           Object value)
        Format to Pair objects.
        Parameters:
        collectionFormat - Either csv (comma separated), tsv (tab separated), or pipes (separated by a pipe character).
        name - Name of the pair.
        value - One or more values of the pair. Can be a string or a Collection.
        Returns:
        The pair formatted according to the given format, e.g. a string with the name and value separated by the given delimiter, and each pair separated from each other by a comma.
      • escapeString

        public String escapeString​(String str)
        Escape the given string to be used as URL query value.
        Parameters:
        str - a String to escape
        Returns:
        the escaped version of the String
      • escapeString

        public String escapeString​(Object str)
        Converts the given object to a string and escapes it so it can be used as URL query value. When null is given, an empty string is returned.
        Parameters:
        str - a String to escape
        Returns:
        the escaped version of the String
      • selectHeaderContentType

        public String selectHeaderContentType​(String[] contentTypes)
        Select the Content-Type header's value from the given array: if JSON exists in the given array, use it; otherwise use the first one of the array.
        Parameters:
        contentTypes - The Content-Type array to select from
        Returns:
        The Content-Type header to use. If the given array is empty, JSON will be used.
      • parseDate

        public Date parseDate​(String str)
        Parse the given string into Date object.
        Parameters:
        str - a string to parse
        Returns:
        a Date object
      • parseOffsetDateTime

        public OffsetDateTime parseOffsetDateTime​(String str)
        Parse the given string into OffsetDateTime object.
        Parameters:
        str - String
        Returns:
        OffsetDateTime