Google Data APIs Client Library (1.41.1)



com.google.gdata.util
Class Version

java.lang.Object
  extended by com.google.gdata.util.Version

public class Version
extends java.lang.Object

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


Field Summary
static int ANY
          The ANY value indicates a version component that will match any revision.
 
Constructor Summary
Version(java.lang.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(java.lang.Class<? extends Service> serviceClass, java.lang.String versionDescription, Version... impliedVersions)
          Creates a new Version instance using a version description with the format [{service}]{major}.{minor}.
 
Method Summary
static Version anyMinorVersionOf(Version v)
          Returns a version that matches the input service type and major version but ANY minor version.
 boolean equals(java.lang.Object o)
           
static Version findServiceVersion(java.util.Collection<? extends Version> versionList, java.lang.Class<? extends Service> serviceClass)
          Finds a matching version for serviceClass in a list of versions, or returns null otherwise.
 java.util.List<Version> getImpliedVersions()
          Returns the list of related services versions that are implied by this version.
 int getMajor()
          Returns the major revision of the version.
 int getMinor()
          Returns the minor revision of the version.
 java.lang.Class<? extends Service> getServiceClass()
          Returns the service type of the version.
 java.lang.String getVersionString()
          Returns the String representation of the version.
 int hashCode()
           
 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.
 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.
 boolean isCompatible(Version v)
          Returns true if the specified version is compatible with this version or one of its implied versions.
 boolean isSameService(Version v)
          Returns true if the target version is for the same service.
 boolean matches(Version v)
          Returns true if the specified version is a match with this version or one of its implied versions.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY

public static final int ANY
The ANY value indicates a version component that will match any revision.

See Also:
Constant Field Values
Constructor Detail

Version

public Version(java.lang.Class<? extends Service> serviceClass,
               int major,
               int minor,
               Version... impliedVersions)
        throws java.lang.NullPointerException,
               java.lang.IllegalArgumentException
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.
Throws:
java.lang.NullPointerException - if the service type is null.
java.lang.IllegalArgumentException - if revision values are invalid.

Version

public Version(java.lang.Class<? extends Service> serviceClass,
               java.lang.String versionDescription,
               Version... impliedVersions)
        throws java.lang.IllegalArgumentException
Creates a new Version instance using a version description with the format [{service}]{major}.{minor}.

Parameters:
serviceClass - the service type.
versionDescription - the service description.
Throws:
java.lang.IllegalArgumentException - if the versionDescription has an invalid syntax or includes a service name that does not match the service type.
Method Detail

findServiceVersion

public static Version findServiceVersion(java.util.Collection<? extends Version> versionList,
                                         java.lang.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.

anyMinorVersionOf

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

getServiceClass

public final java.lang.Class<? extends Service> getServiceClass()
Returns the service type of the version.

Returns:
service type.

getMajor

public final int getMajor()
Returns the major revision of the version.

Returns:
major revision.

getMinor

public final int getMinor()
Returns the minor revision of the version.

Returns:
minor revision.

getVersionString

public final java.lang.String getVersionString()
Returns the String representation of the version.


isSameService

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.

isCompatible

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).


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.


isAfter

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 Integer.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:
java.lang.IllegalArgumentException - if the provided version is not for the same service as this version or for one implied by this version.

isBefore

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 Integer.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:
java.lang.IllegalArgumentException - if the provided version is not for the same service as this version or for one implied by this version.

getImpliedVersions

public java.util.List<Version> getImpliedVersions()
Returns the list of related services versions that are implied by this 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