Package org.wiremock.url
Interface Authority
- All Superinterfaces:
Normalisable<Authority>,org.wiremock.stringparser.ParsedString
- All Known Subinterfaces:
HostAndPort
Represents the authority component of a URI as defined in RFC 3986 Section 3.2.
The authority component consists of optional user information, a host, and an optional port.
It typically takes the form [userinfo@]host[:port].
Implementations must be immutable and thread-safe.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleangetHost()Returns the host component.Returns the host and port as aHostAndPort.Returns an optional representation of the port to distinguish between no port and empty port.@Nullable PortgetPort()Returns the port component, ornullif there is no port.@Nullable UserInfoReturns the user info component, ornullif there is no user info.static intdefault booleandefault booleanisNormalForm(Scheme canonicalScheme) Tests if this value is already normalisedReturns a normalised form of this authority using scheme-specific normalization rules.static AuthorityCreates an authority from user info and host.static AuthorityCreates an authority from user info, host, and port.static AuthorityCreates an authority from a host.static AuthorityCreates an authority from a host and port.static AuthorityParses a string into an authority.default AuthorityReturns a new authority with the port removed.Returns a new authority with the specified port.Methods inherited from interface org.wiremock.url.Normalisable
normaliseMethods inherited from interface org.wiremock.stringparser.ParsedString
toString
-
Method Details
-
getUserInfo
@Nullable UserInfo getUserInfo()Returns the user info component, ornullif there is no user info.- Returns:
- the user info, or
nullif absent
-
getHost
Host getHost()Returns the host component.- Returns:
- the host, never
null
-
getPort
@Nullable Port getPort()Returns the port component, ornullif there is no port.- Returns:
- the port, or
nullif absent
-
getMaybePort
Returns an optional representation of the port to distinguish between no port and empty port.An Authority can legitimately be any of:
example.com- no port (returnsnull)example.com:- empty port (returnsOptional.empty())example.com:80- with port (returnsOptional.of(port))
- Returns:
nullfor no port,Optional.empty()for empty port, orOptional.of(port)for a port value
-
getHostAndPort
HostAndPort getHostAndPort()Returns the host and port as aHostAndPort.- Returns:
- the host and port
-
withPort
Returns a new authority with the specified port.- Parameters:
port- the port to set, ornullto remove it- Returns:
- a new authority with the updated port
-
withoutPort
Returns a new authority with the port removed.- Returns:
- a new authority without a port
-
normalise
Returns a normalised form of this authority using scheme-specific normalization rules.The scheme is used to determine if the port should be removed when it matches the default port for that scheme.
- Parameters:
canonicalScheme- the canonical scheme to use for normalization- Returns:
- a normalised authority
-
isNormalForm
default boolean isNormalForm()- Specified by:
isNormalFormin interfaceNormalisable<Authority>
-
isNormalForm
Tests if this value is already normalised- Parameters:
canonicalScheme- the scheme to be in normal form against- Returns:
- true if in normal form for this scheme
-
parse
Parses a string into an authority.- Parameters:
authorityStr- the string to parse- Returns:
- the parsed authority
- Throws:
IllegalAuthority- if the string is not a valid authority
-
of
Creates an authority from a host.- Parameters:
host- the host- Returns:
- the authority
-
of
Creates an authority from a host and port.- Parameters:
host- the hostport- the port, ornull- Returns:
- the authority
-
of
Creates an authority from user info and host.- Parameters:
userInfo- the user info, ornullhost- the host- Returns:
- the authority
-
of
Creates an authority from user info, host, and port.- Parameters:
userInfo- the user info, ornullhost- the hostport- the port, ornull- Returns:
- the authority
-
equals
-
hashCode
-