Class DVRVersion

java.lang.Object
com.helger.diver.api.version.DVRVersion
All Implemented Interfaces:
Comparable<DVRVersion>

@Immutable @MustImplementComparable @MustImplementEqualsAndHashcode public final class DVRVersion extends Object implements Comparable<DVRVersion>
This class contains the version of a DVR Coordinate. This can either be a static version or a pseudo version. This version type has a specific kind of ordering, so that versions using the classifier "SNAPSHOT" are ordered BEFORE respective release versions. Example order:
  1. 1.0
  2. 1.1-SNAPSHOT
  3. 1.1
  4. 1.2
  5. 1.3-SNAPSHOT
  6. 1.3
Author:
Philip Helger
  • Field Details

    • QUALIFIER_SNAPSHOT

      public static final String QUALIFIER_SNAPSHOT
      Specific qualifier for "SNAPSHOT" versions"
      See Also:
    • NUMERIC_VERSION_PART_SEPARATOR

      public static final char NUMERIC_VERSION_PART_SEPARATOR
      Separator between major and minor and between minor and micro version
      See Also:
    • DEFAULT_CLASSIFIER_SEPARATOR

      public static final char DEFAULT_CLASSIFIER_SEPARATOR
      Separate between classifier and the rest (if available)
      See Also:
  • Method Details

    • isStaticVersion

      public boolean isStaticVersion()
      Returns:
      true if it is a static version, false if it is a pseudo version
      See Also:
    • isStaticSnapshotVersion

      public static boolean isStaticSnapshotVersion(@Nullable String sQualifier)
      Parameters:
      sQualifier - The qualifier to check. May be null.,
      Returns:
      true if the qualifier is "SNAPSHOT".
      Since:
      3.0.0
    • isStaticSnapshotVersion

      public static boolean isStaticSnapshotVersion(@Nullable com.helger.commons.version.Version aVer)
      Parameters:
      aVer - The version to check. May be null.,
      Returns:
      true if the passed version has the the qualifier "SNAPSHOT".
      Since:
      1.0.1
    • isStaticSnapshotVersion

      public boolean isStaticSnapshotVersion()
      Returns:
      true if this is a static version, and if the qualifier is "SNAPSHOT".
      See Also:
    • getStaticVersion

      @Nullable public com.helger.commons.version.Version getStaticVersion()
      Returns:
      The static version of this VER version. Guaranteed to be non-null if isStaticVersion() returns true.
      See Also:
    • isPseudoVersion

      public boolean isPseudoVersion()
      Returns:
      true if it is a pseudo version, false if it is a static version
      See Also:
    • getPseudoVersion

      @Nullable public IDVRPseudoVersion getPseudoVersion()
      Returns:
      The pseudo version of this VER version. Guaranteed to be non-null if isPseudoVersion() returns true.
      See Also:
    • getAsString

      @Nonnull public static String getAsString(@Nonnull com.helger.commons.version.Version aVersion)
    • getAsString

      @Nonnull @Nonempty public static String getAsString(@Nonnull IDVRPseudoVersion aPseudoVersion)
    • getAsString

      @Nonnull public String getAsString()
      Returns:
      The unified string representation of the Version.
    • compareTo

      public int compareTo(@Nonnull DVRVersion rhs)
      Specified by:
      compareTo in interface Comparable<DVRVersion>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      @Nonnull public static DVRVersion of(@Nonnull com.helger.commons.version.Version aVersion)
    • of

      @Nonnull public static DVRVersion of(@Nonnull IDVRPseudoVersion aPseudoVersion)
    • isValidStaticVersion

      public static boolean isValidStaticVersion(@Nullable String sVersion)
      Checks if the provided version is a valid static version.
      • 1.0.0
      • 1.0
      • 1
      • 1.0.0-SNAPSHOT
      • 1.0-SNAPSHOT
      • 1-SNAPSHOT
      • 1.0.0.SNAPSHOT
      • 1.0.SNAPSHOT
      • 1.SNAPSHOT
      Parameters:
      sVersion - The version to check
      Returns:
      true if the version is a valid static version, false if not.
    • parseOrThrow

      @Nonnull public static DVRVersion parseOrThrow(@Nullable String sVersion) throws DVRVersionException
      Throws:
      DVRVersionException
    • parseOrNull

      @Nullable public static DVRVersion parseOrNull(@Nullable String sVersion)
    • getStaticVersionAcceptor

      @Nonnull public static Predicate<DVRVersion> getStaticVersionAcceptor(@Nullable Set<String> aVersionsToIgnore, boolean bIncludeSnapshots)
      Create a Predicate that can be used to filter static DVR versions. The returned predicate may be used as a filter when iterating over entries. This method is only meant to work with static versions and does not consider pseudo versions.
      Parameters:
      aVersionsToIgnore - Optional set of specific versions to ignore. This may be handy to explicitly rule out illegal versions. May be null or empty to indicate that no version should be ignored.
      bIncludeSnapshots - true if SNAPSHOT versions should be allowed by the resulting predicate.
      Returns:
      Never null.