public class

Version

extends Object
java.lang.Object
   ↳ com.google.gdata.util.Version

Class Overview

The Version class is a helper class that describes version information about a particular type of service.

Summary

Constants
int ANY The ANY value indicates a version component that will match any revision.
Fields
private static final Pattern VERSION_PROPERTY_PATTERN Regex that description the format of a version description.
private List<Version> impliedVersions
private int major
private int minor
private Class<? extends Service> serviceClass
Public Constructors
Version(Class<? extends Service> serviceClass, int major, int minor, Version... impliedVersions)
Creates a new Version instance for the specified service and defines the major and minor versions for the service.
Version(Class<? extends Service> serviceClass, String versionDescription, Version... impliedVersions)
Creates a new Version instance using a version description with the format [{service}]{major}.{minor}.
Public Methods
static Version anyMinorVersionOf(Version v)
Returns a version that matches the input service type and major version but ANY minor version.
boolean equals(Object o)
static Version findServiceVersion(Collection<? extends Version> versionList, Class<? extends Service> serviceClass)
Finds a matching version for serviceClass in a list of versions, or returns null otherwise.
List<Version> getImpliedVersions()
Returns the list of related services versions that are implied by this version.
final int getMajor()
Returns the major revision of the version.
final int getMinor()
Returns the minor revision of the version.
final Class<? extends Service> getServiceClass()
Returns the service type of the version.
final String getVersionString()
Returns the String representation of the version.
int hashCode()
final boolean isAfter(Version v)
Returns true if this version is a later version than the argument, on the basis of comparing the major and minor versions.
final boolean isBefore(Version v)
Returns true if this version is a earlier version than the argument, on the basis of comparing the major and minor versions.
final boolean isCompatible(Version v)
Returns true if the specified version is compatible with this version or one of its implied versions.
final boolean isSameService(Version v)
Returns true if the target version is for the same service.
final boolean matches(Version v)
Returns true if the specified version is a match with this version or one of its implied versions.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ANY

The ANY value indicates a version component that will match any revision.

Constant Value: -1 (0xffffffff)

Fields

private static final Pattern VERSION_PROPERTY_PATTERN

Regex that description the format of a version description. The first (optional) group is the service name, followed by a group containing the major version, and then another optional group that contains the minor version number preceded by a dot ('.').

private List<Version> impliedVersions

private int major

private int minor

private Class<? extends Service> serviceClass

Public Constructors

public Version (Class<? extends Service> serviceClass, int major, int minor, Version... impliedVersions)

Creates a new Version instance for the specified service and defines the major and minor versions for the service.

Parameters
serviceClass The service type.
major The major revision number of the service.
minor The minor revision number of the service.
impliedVersions
Throws
NullPointerException if the service type is null.
IllegalArgumentException if revision values are invalid.

public Version (Class<? extends Service> serviceClass, String versionDescription, Version... impliedVersions)

Creates a new Version instance using a version description with the format [{service}]{major}.{minor}.

Parameters
serviceClass The service type.
versionDescription The service description.
impliedVersions
Throws
IllegalArgumentException if the versionDescription has an invalid syntax or includes a service name that does not match the service type.

Public Methods

public static Version anyMinorVersionOf (Version v)

Returns a version that matches the input service type and major version but ANY minor version.

Parameters
v Input version type
Returns
  • equivalent version with any minor version

public boolean equals (Object o)

Parameters
o

public static Version findServiceVersion (Collection<? extends Version> versionList, Class<? extends Service> serviceClass)

Finds a matching version for serviceClass in a list of versions, or returns null otherwise.

Parameters
versionList The list of versions to search.
serviceClass The service class to match.
Returns
  • the matching version or null.

public List<Version> getImpliedVersions ()

Returns the list of related services versions that are implied by this version.

public final int getMajor ()

Returns the major revision of the version.

Returns
  • major revision.

public final int getMinor ()

Returns the minor revision of the version.

Returns
  • minor revision.

public final Class<? extends Service> getServiceClass ()

Returns the service type of the version.

Returns
  • service type.

public final String getVersionString ()

Returns the String representation of the version.

public int hashCode ()

public final boolean isAfter (Version v)

Returns true if this version is a later version than the argument, on the basis of comparing the major and minor versions. For the purposes of comparison, a value of ANY is considered to be MAX_VALUE, so no finite version number may come after it.

Parameters
v Version to compare against
Returns
  • true if this version is later than the argument
Throws
IllegalArgumentException if the provided version is not for the same service as this version or for one implied by this version.

public final boolean isBefore (Version v)

Returns true if this version is a earlier version than the argument, on the basis of comparing the major and minor versions. For the purposes of comparison, a value of ANY is considered to be MIN_VALUE, so no finite version number may come before it.

Parameters
v Version to compare against
Returns
  • true if this version is later than the argument
Throws
IllegalArgumentException if the provided version is not for the same service as this version or for one implied by this version.

public final boolean isCompatible (Version v)

Returns true if the specified version is compatible with this version or one of its implied versions. Two versions are compatible if they are for the same service and have a matching major version number (or one of them has a major version of ANY).

Parameters
v

public final boolean isSameService (Version v)

Returns true if the target version is for the same service.

Parameters
v Target version to check.
Returns
  • true if service matches.

public final boolean matches (Version v)

Returns true if the specified version is a match with this version or one of its implied versions. Two versions are compatible if they are for the same service and have matching major and minor version numbers. A version number is a match if it is the same or one is ANY.

Parameters
v

public String toString ()