Version

public abstract class Version


Class encapsulating a version with major, minor, patch and description values.

Summary

Constants

static final @NonNull Version
static final @NonNull Version
static final @NonNull Version

Public methods

@Override @NonNull int

To compare the major, minor and patch version with another.

@NonNull int
compareTo(@NonNull int majorVersion)

To compare the major number with the input value.

@NonNull int
compareTo(@NonNull int majorVersion, @NonNull int minorVersion)

To compare the major and minor numbers with the input values.

static @NonNull Version
create(
    @NonNull int major,
    @NonNull int minor,
    @NonNull int patch,
    @NonNull String description
)

Creates a new instance of the Version object with the given parameters.

final @Override @NonNull boolean
abstract @NonNull int

Gets the major version number.

final @Override @NonNull int
static @Nullable Version
parse(@NonNull String versionString)

Parses a string to a version object.

final @NonNull @Override String

Constants

VERSION_1_0

@NonNull
public static final @NonNull Version VERSION_1_0

VERSION_1_1

@NonNull
public static final @NonNull Version VERSION_1_1

VERSION_1_2

@NonNull
public static final @NonNull Version VERSION_1_2

Public methods

compareTo

@Override
@NonNull
public @Override int compareTo(@NonNull Version other)

To compare the major, minor and patch version with another.

Parameters
@NonNull Version other

The preference to compare to this one.

Returns
@Override int

0 if it have the same major minor and patch version; less than 0 if this preference sorts ahead of other; greater than 0 if this preference sorts after other.

compareTo

@NonNull
public int compareTo(@NonNull int majorVersion)

To compare the major number with the input value.

compareTo

@NonNull
public int compareTo(@NonNull int majorVersion, @NonNull int minorVersion)

To compare the major and minor numbers with the input values.

create

@NonNull
public static Version create(
    @NonNull int major,
    @NonNull int minor,
    @NonNull int patch,
    @NonNull String description
)

Creates a new instance of the Version object with the given parameters.

equals

@Override
@NonNull
public final @Override boolean equals(@NonNull Object obj)

getMajor

@NonNull
public abstract int getMajor()

Gets the major version number.

hashCode

@Override
@NonNull
public final @Override int hashCode()

parse

@Nullable
@NonNull
public static Version parse(@NonNull String versionString)

Parses a string to a version object.

Parameters
@NonNull String versionString

string in the format "1.2.3" or "1.2.3-Description" (major.minor.patch[-description])

Returns
Version

the parsed Version object or null if the versionString format is invalid.

toString

@NonNull
@Override
public final @Override String toString()