Class Version

  • All Implemented Interfaces:
    java.lang.Comparable<Version>

    public class Version
    extends java.lang.Object
    implements java.lang.Comparable<Version>
    The value object to represent a version consisting of major, minor and patch part.
    Since:
    1.0.0
    Author:
    Mercy
    • Constructor Detail

      • Version

        public Version​(int major)
      • Version

        public Version​(int major,
                       int minor)
      • Version

        public Version​(int major,
                       int minor,
                       int patch)
    • Method Detail

      • of

        public static Version of​(int major)
      • of

        public static Version of​(int major,
                                 int minor)
      • of

        public static Version of​(int major,
                                 int minor,
                                 int patch)
      • of

        public static Version of​(java.lang.String version)
      • getVersion

        @Nonnull
        public static Version getVersion​(java.lang.Class<?> targetClass)
        Class that exposes the version. Fetches the "Implementation-Version" manifest attribute from the jar file.
        Parameters:
        targetClass - the class to exposes the version
        Returns:
        non-null
      • getMajor

        public int getMajor()
        The major version
        Returns:
        major version
      • getMinor

        public int getMinor()
        The minor version
        Returns:
        minor version
      • getPatch

        public int getPatch()
        The patch
        Returns:
        patch
      • gt

        public boolean gt​(Version that)
        Current Version is greater than that
        Parameters:
        that - the version to be compared
        Returns:
        true if greater than, or false
        See Also:
        isGreaterThan(Version)
      • isGreaterThan

        public boolean isGreaterThan​(Version that)
        Current Version is greater than that
        Parameters:
        that - the version to be compared
        Returns:
        true if greater than, or false
        See Also:
        gt(Version)
      • ge

        public boolean ge​(Version that)
        Current Version is greater than or equal to that
        Parameters:
        that - the version to be compared
        Returns:
        true if greater than, or false
        See Also:
        isGreaterOrEqual(Version)
      • isGreaterOrEqual

        public boolean isGreaterOrEqual​(Version that)
        Current Version is greater than or equal to that
        Parameters:
        that - the version to be compared
        Returns:
        true if greater than, or false
        See Also:
        ge(Version)
      • lt

        public boolean lt​(Version that)
        Current Version is less than that
        Parameters:
        that - the version to be compared
        Returns:
        true if less than, or false
      • isLessThan

        public boolean isLessThan​(Version that)
        Current Version is less than that
        Parameters:
        that - the version to be compared
        Returns:
        true if less than, or false
      • le

        public boolean le​(Version that)
        Current Version is less than or equal to that
        Parameters:
        that - the version to be compared
        Returns:
        true if less than, or false
        See Also:
        isLessOrEqual(Version)
      • isLessOrEqual

        public boolean isLessOrEqual​(Version that)
        Current Version is less than or equal to that
        Parameters:
        that - the version to be compared
        Returns:
        true if less than, or false
        See Also:
        le(Version)
      • eq

        public boolean eq​(Version that)
        Current Version is equal to that
        Parameters:
        that - the version to be compared
        Returns:
        true if equals, or false
      • equals

        public boolean equals​(Version that)
        Current Version is equal to that
        Parameters:
        that - the version to be compared
        Returns:
        true if equals, or false
      • equals

        public boolean equals​(java.lang.Object o)
        Current Version is equal to that
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the version to be compared
        Returns:
        true if equals, or false
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(Version that)
        Specified by:
        compareTo in interface java.lang.Comparable<Version>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object