Class ClientVersion

All Implemented Interfaces:
Serializable, Cloneable, Header, NameValuePair

@Header("Client-Version") public class ClientVersion extends BasicStringHeader
Represents a parsed Client-Version HTTP request header.

Specifies a client-side version number.

Example

Client-Version: 2.0.1

Not part of the RFC2616 specification, but provided to allow for HTTP responses to be tailored to specified known client versions.

See Also:
  • Constructor Details

    • ClientVersion

      public ClientVersion(String value)
      Constructor.
      Parameters:
      value - The header value.
      Must be parsable by Version.of(String)
      Can be null.
    • ClientVersion

      public ClientVersion(Version value)
      Constructor.
      Parameters:
      value - The header value.
      Can be null.
    • ClientVersion

      public ClientVersion(Supplier<Version> value)
      Constructor with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      value - The supplier of the header value.
      Can be null.
  • Method Details

    • of

      public static ClientVersion of(String value)
      Static creator.
      Parameters:
      value - The header value.
      Must be parsable by Version.of(String)
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
    • of

      public static ClientVersion of(Version value)
      Static creator.
      Parameters:
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
    • of

      public static ClientVersion of(Supplier<Version> value)
      Static creator with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      value - The supplier of the header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicStringHeader
    • asVersion

      Returns the header value as a Version object.
      Returns:
      The header value as a Version object, or Optional.empty() if the value is null.
    • assertVersion

      Provides the ability to perform fluent-style assertions on this header.
      Examples:

      // Validates the response content is older than 1. client .get(URL) .run() .getHeader(ClientVersion.class).assertVersion().major().isGreaterThan(1);

      Returns:
      A new fluent assertion object.
      Throws:
      AssertionError - If assertion failed.