com.android.ide.common.repository
Class GradleVersion

java.lang.Object
  extended by com.android.ide.common.repository.GradleVersion
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<GradleVersion>

public class GradleVersion
extends java.lang.Object
implements java.lang.Comparable<GradleVersion>, java.io.Serializable

Supports versions in the given formats:

A version can also be a "preview" (e.g. 1-alpha1, 1.0.0-rc2) or an unreleased version (or "snapshot") (e.g. 1-SNAPSHOT, 1.0.0-alpha1-SNAPSHOT).

See Also:
Serialized Form

Nested Class Summary
static class GradleVersion.VersionSegment
           
 
Constructor Summary
GradleVersion(int major, int minor, int micro)
           
 
Method Summary
 int compareIgnoringQualifiers(GradleVersion version)
           
 int compareIgnoringQualifiers(java.lang.String version)
           
 int compareTo(GradleVersion version)
           
 int compareTo(java.lang.String version)
           
 boolean equals(java.lang.Object o)
           
 java.util.List<GradleVersion.VersionSegment> getAdditionalSegments()
           
 int getMajor()
           
 GradleVersion.VersionSegment getMajorSegment()
           
 int getMicro()
           
 GradleVersion.VersionSegment getMicroSegment()
           
 int getMinor()
           
 GradleVersion.VersionSegment getMinorSegment()
           
 int getPreview()
           
 java.lang.String getPreviewType()
           
 int hashCode()
           
 boolean isSnapshot()
           
static GradleVersion parse(java.lang.String value)
          Parses the given version.
 java.lang.String toString()
           
static GradleVersion tryParse(java.lang.String value)
          Parses the given version.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GradleVersion

public GradleVersion(int major,
                     int minor,
                     int micro)
Method Detail

tryParse

@Nullable
public static GradleVersion tryParse(@NonNull
                                              java.lang.String value)
Parses the given version. This method does the same as parse(String), but it does not throw exceptions if the given value does not conform with any of the supported version formats.

Parameters:
value - the version to parse.
Returns:
the created Version object, or null if the given value does not conform with any of the supported version formats.

parse

@NonNull
public static GradleVersion parse(@NonNull
                                          java.lang.String value)
Parses the given version.

Parameters:
value - the version to parse.
Returns:
the created Version object.
Throws:
java.lang.IllegalArgumentException - if the given value does not conform with any of the supported version formats.

getMajor

public int getMajor()

getMajorSegment

@NonNull
public GradleVersion.VersionSegment getMajorSegment()

getMinor

public int getMinor()

getMinorSegment

@Nullable
public GradleVersion.VersionSegment getMinorSegment()

getMicro

public int getMicro()

getMicroSegment

@Nullable
public GradleVersion.VersionSegment getMicroSegment()

getPreview

public int getPreview()

getPreviewType

@Nullable
public java.lang.String getPreviewType()

isSnapshot

public boolean isSnapshot()

compareTo

public int compareTo(@NonNull
                     java.lang.String version)

compareTo

public int compareTo(@NonNull
                     GradleVersion version)
Specified by:
compareTo in interface java.lang.Comparable<GradleVersion>

compareIgnoringQualifiers

public int compareIgnoringQualifiers(@NonNull
                                     java.lang.String version)

compareIgnoringQualifiers

public int compareIgnoringQualifiers(@NonNull
                                     GradleVersion version)

equals

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

hashCode

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

toString

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

getAdditionalSegments

@NonNull
public java.util.List<GradleVersion.VersionSegment> getAdditionalSegments()
Returns:
version segments present after the "micro" segments. For example, parsing "1.2.3.4.5" will result in "4" and "5" to be considered "additional" version segments.