com.android.sdklib.repository
Class PreciseRevision

java.lang.Object
  extended by com.android.sdklib.repository.FullRevision
      extended by com.android.sdklib.repository.PreciseRevision
All Implemented Interfaces:
java.lang.Comparable<FullRevision>

public class PreciseRevision
extends FullRevision

A FullRevision 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
 
Nested classes/interfaces inherited from class com.android.sdklib.repository.FullRevision
FullRevision.PreviewComparison
 
Field Summary
 
Fields inherited from class com.android.sdklib.repository.FullRevision
DEFAULT_SEPARATOR, IMPLICIT_MICRO_REV, IMPLICIT_MINOR_REV, MISSING_MAJOR_REV, NOT_A_PREVIEW, NOT_SPECIFIED, PRECISION_MAJOR, PRECISION_MICRO, PRECISION_MINOR, PRECISION_PREVIEW
 
Constructor Summary
PreciseRevision(int major)
           
PreciseRevision(int major, int minor)
           
PreciseRevision(int major, int minor, int micro)
           
PreciseRevision(int major, int minor, int micro, int preview)
           
 
Method Summary
 int compareTo(PreciseRevision rhs, FullRevision.PreviewComparison comparePreview)
           
 boolean equals(java.lang.Object rhs)
           
 int hashCode()
           
static PreciseRevision parseRevision(java.lang.String revision)
          Parses a string of format "major.minor.micro rcPreview" and returns a new PreciseRevision for it.
 int[] toIntArray(boolean includePreview)
          Returns the version number as an integer array, in the form [major, minor, micro] or [major, minor, micro, preview].
 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 com.android.sdklib.repository.FullRevision
compareTo, compareTo, getMajor, getMicro, getMinor, getPreview, getSeparator, isPreview, parseRevisionImpl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreciseRevision

public PreciseRevision(int major)

PreciseRevision

public PreciseRevision(int major,
                       int minor)

PreciseRevision

public PreciseRevision(int major,
                       int minor,
                       int micro)

PreciseRevision

public PreciseRevision(int major,
                       int minor,
                       int micro,
                       int preview)
Method Detail

parseRevision

@NonNull
public static PreciseRevision parseRevision(@NonNull
                                                    java.lang.String revision)
                                     throws java.lang.NumberFormatException
Parses a string of format "major.minor.micro rcPreview" and returns a new PreciseRevision for it. All the fields except major are optional.

Parameters:
revision - A non-null revision to parse.
Returns:
A new non-null PreciseRevision.
Throws:
java.lang.NumberFormatException - if the parsing failed.

toString

public java.lang.String toString()
Returns the version in a fixed format major.minor.micro with an optional "rc preview#". For example it would return "18.0.0", "18.1.0" or "18.1.2 rc5".

Overrides:
toString in class FullRevision

toShortString

public java.lang.String toShortString()
Description copied from class: FullRevision
Returns the version in a dynamic format "major.minor.micro rc#". This is similar to FullRevision.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".

Overrides:
toShortString in class FullRevision

toIntArray

public int[] toIntArray(boolean includePreview)
Description copied from class: FullRevision
Returns the version number as an integer array, in the form [major, minor, micro] or [major, minor, micro, preview]. This is useful to initialize an instance of org.apache.tools.ant.util.DeweyDecimal using a FullRevision.

Overrides:
toIntArray in class FullRevision
Parameters:
includePreview - If true the output will contain 4 fields to include the preview number (even if 0.) If false the output will contain only 3 fields (major, minor and micro.)
Returns:
A new int array, never null, with either 3 or 4 fields.

hashCode

public int hashCode()
Overrides:
hashCode in class FullRevision

equals

public boolean equals(java.lang.Object rhs)
Overrides:
equals in class FullRevision

compareTo

public int compareTo(PreciseRevision rhs,
                     FullRevision.PreviewComparison comparePreview)