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:
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user