Fixes #976 Now uses GitHub to retrieve most current version

Reworked whole Version Checker with an extensible interface to add any other service later on easier.
The version checker now has its own config file, to collect the different options and extract them from the main config file.
In that you can specify how fine the versions should be checked.
This commit is contained in:
thatsIch
2015-03-09 17:35:19 +01:00
parent 720b38442e
commit 6baf952904
33 changed files with 2023 additions and 169 deletions
@@ -0,0 +1,91 @@
package appeng.services.version;
/**
* Base version of {@link Version}.
*
* Provides a unified way to test for equality and print a formatted string
*/
public abstract class BaseVersion implements Version
{
private final int revision;
private final Channel channel;
private final int build;
/**
* @param revision revision in natural number
* @param channel channel
* @param build build in natural number
*
* @throws AssertionError if assertion are enabled and revision or build are not natural numbers
*/
public BaseVersion( int revision, Channel channel, int build )
{
assert revision >= 0;
assert build >= 0;
this.revision = revision;
this.channel = channel;
this.build = build;
}
@Override
public final int revision()
{
return this.revision;
}
@Override
public final Channel channel()
{
return this.channel;
}
@Override
public final int build()
{
return this.build;
}
@Override
public String formatted()
{
return "rv" + this.revision + '-' + this.channel.name().toLowerCase() + '-' + this.build;
}
@Override
public final int hashCode()
{
int result = this.revision;
result = 31 * result + ( this.channel != null ? this.channel.hashCode() : 0 );
result = 31 * result + this.build;
return result;
}
@Override
public final boolean equals( Object o )
{
if ( this == o )
return true;
if ( !( o instanceof Version ) )
return false;
Version that = (Version) o;
if ( this.revision != that.revision() )
return false;
if ( this.build != that.build() )
return false;
return this.channel == that.channel();
}
@Override
public final String toString()
{
return "Version{" +
"revision=" + this.revision +
", channel=" + this.channel +
", build=" + this.build +
'}';
}
}