Interface Port
- All Superinterfaces:
Normalisable<Port>,org.wiremock.stringparser.ParsedString
An implementation must be immutable (and hence threadsafe)
Implementations must enforce that 1 <= port <= 65,535
Implementations should be equal to any other Port implementation with the same text
representation. Implementations are NOT equal if they have different string
representations, even if they represent the same port number. For example,
Port.parse("00080").equals(Port.of(80)) == false because their string representations differ
("00080" vs "80"), even though both represent port 80. This preserves the original format as it
appeared in the URL.
An implementation's toString should return the String used when it was created. For ports
created via parse(), this preserves the original format including any leading zeros. For
ports created via of(), this returns the canonical form without leading zeros.
An implementation's hashCode() is based on the string representation, ensuring consistency with equals.
-
Method Details
-
getIntValue
int getIntValue() -
isNormalForm
boolean isNormalForm()- Specified by:
isNormalFormin interfaceNormalisable<Port>
-
normalise
Port normalise()Returns a Port with the canonical (normalised) string representation of this port number, without any leading zeros.For example,
Port.parse("00080").normalise()returns a Port whosetoString()is "80".If this Port is already in canonical form, returns a Port equal to this one.
- Specified by:
normalisein interfaceNormalisable<Port>- Returns:
- a Port with the canonical string representation
-
parse
- Throws:
IllegalPort
-
of
- Throws:
IllegalPort
-