Package net.shibboleth.idp.plugin
Class PluginVersion
- java.lang.Object
-
- net.shibboleth.idp.plugin.PluginVersion
-
- All Implemented Interfaces:
Comparable<PluginVersion>
public final class PluginVersion extends Object implements Comparable<PluginVersion>
A version string (Major.minor.patch) as a handy class.
-
-
Constructor Summary
Constructors Constructor Description PluginVersion(int maj, int min, int pat)Constructor.PluginVersion(String version)Constructor.PluginVersion(IdPPlugin plugin)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(PluginVersion other)Compares this object with the specified object for order.booleanequals(Object obj)intgetMajor()Get the major version.intgetMinor()Get the minor version.intgetPatch()Get the patch version.inthashCode()booleanisNull()Is this version all zeros (usually as a result of a parsing issue.private intparseValue(String valueAsString)Helper function for the constructor.StringtoString()
-
-
-
Field Detail
-
MAX_VNO
private static final int MAX_VNO
arbitrary maximum (to help hashing and sanity).- See Also:
- Constant Field Values
-
major
private int major
Major version.
-
minor
private int minor
Minor version.
-
patch
private int patch
Patch version.
-
-
Constructor Detail
-
PluginVersion
public PluginVersion(String version) throws NumberFormatException
Constructor.- Parameters:
version- what to build from- Throws:
NumberFormatException- if it doesn't fit a 1.2.3 format or if the values are out of range
-
PluginVersion
public PluginVersion(@Nonnull IdPPlugin plugin) throws NumberFormatExceptionConstructor.- Parameters:
plugin- what to get the version of.- Throws:
NumberFormatException- if the values are out of range
-
PluginVersion
public PluginVersion(int maj, int min, int pat) throws NumberFormatExceptionConstructor.- Parameters:
maj- Major Versionmin- Minor Versionpat- Patch Version- Throws:
NumberFormatException- if the values are out of range
-
-
Method Detail
-
getMajor
public int getMajor()
Get the major version.- Returns:
- Returns the major version.
-
getMinor
public int getMinor()
Get the minor version.- Returns:
- Returns the minor version.
-
getPatch
public int getPatch()
Get the patch version.- Returns:
- Returns the patch version.
-
isNull
public boolean isNull()
Is this version all zeros (usually as a result of a parsing issue.- Returns:
- if all nulls
-
parseValue
private int parseValue(String valueAsString) throws NumberFormatException
Helper function for the constructor. Parse a string into an int with a range check.- Parameters:
valueAsString- what to parse- Returns:
- the value as an int
- Throws:
NumberFormatException- ifInteger.parseInt(String, int)does or if the value is less than 0 or >MAX_VNO.
-
compareTo
public int compareTo(PluginVersion other)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareToin interfaceComparable<PluginVersion>
-
-