com.android.ide.common.repository
Class GradleVersion
java.lang.Object
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:
- major (e.g. 1)
- major.minor (e.g.
1.0)
- major.minor.micro (e.g. 1.1.1)
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
|
Constructor Summary |
GradleVersion(int major,
int minor,
int micro)
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
GradleVersion
public GradleVersion(int major,
int minor,
int micro)
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.