Class UserAgents

java.lang.Object
com.palantir.conjure.java.api.config.service.UserAgents

public final class UserAgents extends Object
  • Field Details

  • Method Details

    • format

      @Safe public static @Safe String format(@Safe @Safe UserAgent userAgent)
      Returns the canonical string format for the given UserAgent.
    • parse

      public static UserAgent parse(@Safe @Safe String userAgent)
      Parses the given string into a UserAgent or throws an IllegalArgumentException if no correctly formatted primary user agent can be found. Incorrectly formatted informational agents are omitted.

      Valid user agent strings loosely follow RFC 7230 (https://tools.ietf.org/html/rfc7230#section-3.2.6).

    • tryParse

      public static UserAgent tryParse(@Safe @Safe String userAgent)
      Like parse(String), but never fails and returns the primary agent unknown/0.0.0 if no valid primary agent can be parsed.
    • tryParsePrimaryName

      public static String tryParsePrimaryName(@Safe @Safe String userAgent)
      Parse and return only the `name` component of the primary user-agent string, or "unknown" if no valid primary agent name can be parsed. This is functionally similar to calling `tryParse(userAgent).primary().name()`, but optimized to not use regular expressions.