Skip to content

Commit

Permalink
Adds VersionImpl
Browse files Browse the repository at this point in the history
Replaces AbstractVersion with a complete implementation.
  • Loading branch information
bgrozev committed Jul 29, 2019
1 parent 49ed569 commit aca0e20
Showing 1 changed file with 95 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,38 @@
package org.jitsi.utils.version;

/**
* Base class for <tt>Version</tt> implementation that uses major, minor and
* nightly build id for versioning purposes.
* An implementation of {@link Version}.
*
* @author Emil Ivov
* @author Pawel Domas
* @author Boris Grozev
*/
public abstract class AbstractVersion
implements Version
public class VersionImpl implements Version
{
/**
* The application name field.
*/
private final String applicationName;

/**
* The version major field.
*/
private int versionMajor;
private final int versionMajor;

/**
* The version minor field.
*/
private int versionMinor;
private final int versionMinor;

/**
* The nightly build id field.
*/
private String nightlyBuildID;
private final String nightlyBuildID;

/**
* The pre-release ID field.
*/
private final String preReleaseId;

/**
* Creates version object with custom major, minor and nightly build id.
Expand All @@ -47,49 +56,80 @@ public abstract class AbstractVersion
* @param minorVersion the minor version to use.
* @param nightlyBuildID the nightly build id value for new version object.
*/
protected AbstractVersion(int majorVersion,
int minorVersion,
String nightlyBuildID)
public VersionImpl(String applicationName,
int majorVersion,
int minorVersion)
{
this(applicationName, majorVersion, minorVersion, null);
}

/**
* Creates version object with custom major, minor and nightly build id.
*
* @param majorVersion the major version to use.
* @param minorVersion the minor version to use.
* @param nightlyBuildID the nightly build id value for new version object.
*/
public VersionImpl(String applicationName,
int majorVersion,
int minorVersion,
String nightlyBuildID)
{
this(applicationName, majorVersion, minorVersion, nightlyBuildID, null);
}

/**
* Creates version object with custom major, minor and nightly build id.
*
* @param majorVersion the major version to use.
* @param minorVersion the minor version to use.
* @param nightlyBuildID the nightly build id value for new version object.
*/
public VersionImpl(String applicationName,
int majorVersion,
int minorVersion,
String nightlyBuildID,
String preReleaseId)
{
this.applicationName = applicationName;
this.versionMajor = majorVersion;
this.versionMinor = minorVersion;
this.nightlyBuildID = nightlyBuildID;
this.preReleaseId = preReleaseId;
}


/**
* Returns the version major of the current Jitsi version. In an
* example 2.3.1 version string 2 is the version major. The version major
* number changes when a relatively extensive set of new features and
* possibly rearchitecturing have been applied to the Jitsi.
*
* @return the version major String.
* {@inheritDoc}
*/
@Override
public int getVersionMajor()
{
return versionMajor;
}

/**
* Returns the version minor of the current Jitsi version. In an
* example 2.3.1 version string 3 is the version minor. The version minor
* number changes after adding enhancements and possibly new features to a
* given Jitsi version.
*
* @return the version minor integer.
* {@inheritDoc}
*/
@Override
public int getVersionMinor()
{
return versionMinor;
}

/**
* If this is a nightly build, returns the build identifies (e.g.
* nightly-2007.12.07-06.45.17). If this is not a nightly build Jitsi
* version, the method returns null.
*
* @return a String containing a nightly build identifier or null if this is
* a release version and therefore not a nightly build
* {@inheritDoc}
*/
@Override
public boolean isNightly()
{
return nightlyBuildID != null;
}

/**
* {@inheritDoc}
*/
@Override
public String getNightlyBuildID()
{
if(!isNightly())
Expand All @@ -99,17 +139,25 @@ public String getNightlyBuildID()
}

/**
* Compares another <tt>Version</tt> object to this one and returns a
* negative, zero or a positive integer if this version instance represents
* respectively an earlier, same, or later version as the one indicated
* by the <tt>version</tt> parameter.
*
* @param version the <tt>Version</tt> instance that we'd like to compare
* to this one.
*
* @return a negative integer, zero, or a positive integer as this object
* represents a version that is earlier, same, or more recent than the one
* referenced by the <tt>version</tt> parameter.
* {@inheritDoc}
*/
@Override
public boolean isPreRelease()
{
return preReleaseId != null;
}

/**
* {@inheritDoc}
*/
@Override
public String getPreReleaseID()
{
return preReleaseId;
}

/**
* {@inheritDoc}
*/
public int compareTo(Version version)
{
Expand Down Expand Up @@ -173,14 +221,7 @@ private static int compareNightlyBuildIDByComponents(String v1, String v2)
}

/**
* Compares the <tt>version</tt> parameter to this version and returns true
* if and only if both reference the same Jitsi version and
* false otherwise.
*
* @param version the version instance that we'd like to compare with this
* one.
* @return true if and only the version param references the same
* Jitsi version as this Version instance and false otherwise.
* {@inheritDoc}
*/
@Override
public boolean equals(Object version)
Expand All @@ -194,6 +235,12 @@ public boolean equals(Object version)
return toString().equals(version.toString());
}

@Override
public String getApplicationName()
{
return applicationName;
}

/**
* @see java.lang.Object#hashCode()
*/
Expand All @@ -204,9 +251,7 @@ public boolean equals(Object version)

/**
* Returns a String representation of this Version instance in the generic
* form of major.minor[.nightly.build.id]. If you'd just like to obtain the
* version of Jitsi so that you could display it (e.g. in a Help->About
* dialog) then all you need is calling this method.
* form of major.minor[.nightly.build.id].
*
* @return a major.minor[.build] String containing the complete
* Jitsi version.
Expand Down

0 comments on commit aca0e20

Please sign in to comment.