Class ResponseVersion
java.lang.Object
com.tccc.kos.commons.util.dispatcher.ResponseVersion
Data class that holds an HTTP/REST endpoint's version number, which is used in the ResponseEnvelope.
The version number has the form "major.minor".
Data Fields
It contains just two fields:
private int major; // the major version number
private int minor; // the minor version number
Example2
ResponseVersion responseVersion1 = new ResponseVersion(); // ver = "0.0"
ResponseVersion responseVersion2 = new ResponseVersion(1, 2); // ver = "1.2"
ResponseVersion responseVersion3 = new ResponseVersion("3"); // ver = "3.0"
ResponseVersion responseVersion4 = new ResponseVersion("4.5.6.7"); // ver = "4.5"
ResponseVersion responseVersion5 = new ResponseVersion("foo.bar"); // throws exception
- Since:
- 1.0
- Version:
- 2022-08-30
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty version whose major and minor numbers are both zero.ResponseVersion
(int major, int minor) Constructs a version with the given major and minor values.ResponseVersion
(String str) Constructs a version from the specified string. -
Method Summary
-
Constructor Details
-
ResponseVersion
public ResponseVersion()Constructs an empty version whose major and minor numbers are both zero. -
ResponseVersion
public ResponseVersion(int major, int minor) Constructs a version with the given major and minor values.- Parameters:
major
- the major versionminor
- the minor version
-
ResponseVersion
Constructs a version from the specified string. The string should be either "major.minor" or "major.minor.patch" or "major.minor.patch.build". An exception is thrown if the version string is invalid.- Parameters:
str
- the version string to parse- Throws:
IllegalArgumentException
- when the givenstr
is invalid
-
-
Method Details
-
toString
Returns the string representation of this object which is simply "major.minor". -
getMajor
public int getMajor() -
getMinor
public int getMinor() -
setMajor
public void setMajor(int major) -
setMinor
public void setMinor(int minor)
-