|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.android.repository.Revision
public class Revision
A Revision which distinguishes between x and x.0, x.0.0, x.y.0, etc; it basically
keeps track of the precision of the revision string.
This is vital when referencing Gradle artifact numbers, since versions x.y.0 and version x.y are not the same.
| Nested Class Summary | |
|---|---|
static class |
Revision.Precision
|
static class |
Revision.PreviewComparison
Indicates how to compare the preview field in compareTo(Revision,
PreviewComparison) |
| Field Summary | |
|---|---|
protected static java.lang.String |
DEFAULT_SEPARATOR
|
static int |
IMPLICIT_MICRO_REV
|
static int |
IMPLICIT_MINOR_REV
|
static int |
MISSING_MAJOR_REV
|
static int |
NOT_A_PREVIEW
|
static Revision |
NOT_SPECIFIED
|
| Constructor Summary | |
|---|---|
Revision(int major)
Creates a new Revision with the specified major revision and no other revision
components. |
|
Revision(int major,
int minor)
Creates a new Revision with the specified major and minor revision components and no
others. |
|
Revision(int major,
java.lang.Integer minor,
java.lang.Integer micro,
java.lang.Integer preview)
Creates a new Revision with the specified components. |
|
Revision(int major,
int minor,
int micro)
Creates a new Revision with the specified major, minor, and micro revision components
and no preview component. |
|
Revision(int major,
int minor,
int micro,
int preview)
Creates a new Revision with the specified components. |
|
Revision(Revision revision)
Creates a copy of the specified Revision. |
|
| Method Summary | |
|---|---|
int |
compareTo(Revision rhs)
Trivial comparison of a version, e.g 17.1.2 < 18.0.0. |
int |
compareTo(Revision rhs,
Revision.PreviewComparison comparePreview)
Trivial comparison of a version, e.g 17.1.2 < 18.0.0. |
boolean |
equals(java.lang.Object rhs)
Returns true if this revision is equal, including in precision to rhs. |
int |
getMajor()
|
int |
getMicro()
|
int |
getMinor()
|
int |
getPreview()
|
protected java.lang.String |
getSeparator()
|
int |
hashCode()
|
boolean |
isPreview()
|
static Revision |
parseRevision(java.lang.String revisionString)
Parses a string of format "major.minor.micro rcPreview" and returns a new Revision
for it. |
static Revision |
parseRevision(java.lang.String revisionString,
Revision.Precision minimumPrecision)
Parses a string of format "major.minor.micro rcPreview" and returns a new Revision
for it. |
int[] |
toIntArray(boolean includePreview)
Returns an int[] containing the Major, Minor, and Micro (and optionally Preview)
components (if specified) of this revision |
java.lang.String |
toShortString()
Returns the version in a dynamic format "major.minor.micro rc#". |
java.lang.String |
toString()
Returns the version in a fixed format major.minor.micro with an optional "rc preview#". |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MISSING_MAJOR_REV
public static final int IMPLICIT_MINOR_REV
public static final int IMPLICIT_MICRO_REV
public static final int NOT_A_PREVIEW
public static final Revision NOT_SPECIFIED
protected static final java.lang.String DEFAULT_SEPARATOR
| Constructor Detail |
|---|
public Revision(int major)
Revision with the specified major revision and no other revision
components.
public Revision(int major,
int minor)
Revision with the specified major and minor revision components and no
others.
public Revision(@NonNull
Revision revision)
Revision.
public Revision(int major,
int minor,
int micro)
Revision with the specified major, minor, and micro revision components
and no preview component.
public Revision(int major,
int minor,
int micro,
int preview)
Revision with the specified components.
public Revision(int major,
@Nullable
java.lang.Integer minor,
@Nullable
java.lang.Integer micro,
@Nullable
java.lang.Integer preview)
Revision with the specified components. The precision will be exactly
sufficient to include all non-null components.
| Method Detail |
|---|
@NonNull
public static Revision parseRevision(@NonNull
java.lang.String revisionString,
@NonNull
Revision.Precision minimumPrecision)
throws java.lang.NumberFormatException
Revision
for it.
All the fields except major are optional.
revisionString - A non-null revisionString to parse.minimumPrecision - Create a Revision with at least the given precision,
regardless of how precise the revisionString is.
Revision.
java.lang.NumberFormatException - if the parsing failed.
@NonNull
public static Revision parseRevision(@NonNull
java.lang.String revisionString)
throws java.lang.NumberFormatException
Revision
for it.
All the fields except major are optional.
revisionString - A non-null revisionString to parse.
Revision, with precision depending on the precision of revisionString.
java.lang.NumberFormatException - if the parsing failed.public java.lang.String toString()
toString in class java.lang.Object@NonNull public int[] toIntArray(boolean includePreview)
int[] containing the Major, Minor, and Micro (and optionally Preview)
components (if specified) of this revision
includePreview - If false, the preview component of this revision will be ignored.
includePreview is true, the result will
always be of length 4.
public boolean equals(@Nullable
java.lang.Object rhs)
true if this revision is equal, including in precision to rhs.
That is, (new Revision(20)).equals(new Revision(20, 0, 0) will return false.
equals in class java.lang.Objectpublic int getMajor()
public int getMinor()
public int getMicro()
@NonNull protected java.lang.String getSeparator()
public boolean isPreview()
public int getPreview()
@NonNull public java.lang.String toShortString()
toString() except it omits minor, micro or preview versions when they are zero. For example
it would return "18 rc1" instead of "18.0.0 rc1", or "18.1 rc2" instead of "18.1.0 rc2".
public int hashCode()
hashCode in class java.lang.Object
public int compareTo(@NonNull
Revision rhs)
compareTo in interface java.lang.Comparable<Revision>rhs - The right-hand side Revision to compare with.
public int compareTo(@NonNull
Revision rhs,
@NonNull
Revision.PreviewComparison comparePreview)
rhs - The right-hand side Revision to compare with.comparePreview - How to compare the preview value.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||