2018-09-22 17:22:39 +03:00
|
|
|
package ru.gravit.utils;
|
2018-09-17 10:07:32 +03:00
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
2018-09-22 17:22:39 +03:00
|
|
|
import ru.gravit.launcher.LauncherAPI;
|
2018-09-17 10:07:32 +03:00
|
|
|
|
2018-09-22 17:22:39 +03:00
|
|
|
public class Version {
|
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public final int major;
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public final int minor;
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public final int patch;
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public final int build;
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public final Type release;
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public Version(int major, int minor, int patch) {
|
2018-09-17 10:07:32 +03:00
|
|
|
this.major = major;
|
|
|
|
this.minor = minor;
|
|
|
|
this.patch = patch;
|
|
|
|
build = 0;
|
|
|
|
release = Type.UNKNOWN;
|
|
|
|
}
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public Version(int major, int minor, int patch, int build) {
|
2018-09-17 10:07:32 +03:00
|
|
|
this.major = major;
|
|
|
|
this.minor = minor;
|
|
|
|
this.patch = patch;
|
|
|
|
this.build = build;
|
|
|
|
release = Type.UNKNOWN;
|
|
|
|
}
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
|
|
|
public Version(int major, int minor, int patch, int build, Type release) {
|
2018-09-17 10:07:32 +03:00
|
|
|
this.major = major;
|
|
|
|
this.minor = minor;
|
|
|
|
this.patch = patch;
|
|
|
|
this.build = build;
|
|
|
|
this.release = release;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
2018-09-22 17:22:39 +03:00
|
|
|
Version that = (Version) o;
|
2018-09-17 10:07:32 +03:00
|
|
|
return major == that.major &&
|
|
|
|
minor == that.minor &&
|
|
|
|
patch == that.patch &&
|
|
|
|
build == that.build;
|
|
|
|
}
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public String getVersionString() {
|
|
|
|
return String.format("%d.%d.%d", major, minor, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public int hashCode() {
|
|
|
|
return Objects.hash(major, minor, patch, build);
|
|
|
|
}
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public String getReleaseStatus()
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
switch (release) {
|
|
|
|
case LTS:
|
|
|
|
result="lts";
|
|
|
|
break;
|
|
|
|
case STABLE:
|
|
|
|
result="stable";
|
|
|
|
break;
|
|
|
|
case BETA:
|
|
|
|
result="beta";
|
|
|
|
break;
|
|
|
|
case ALPHA:
|
|
|
|
result="alpha";
|
|
|
|
break;
|
|
|
|
case DEV:
|
|
|
|
result="dev";
|
|
|
|
break;
|
|
|
|
case EXPERIMENTAL:
|
|
|
|
result="experimental";
|
|
|
|
break;
|
|
|
|
case UNKNOWN:
|
|
|
|
result="";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result="";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
@Override
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public String toString() {
|
|
|
|
return String.format("%d.%d.%d-%d %s", major, minor, patch, build,getReleaseStatus());
|
|
|
|
}
|
2018-09-22 17:22:39 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 13:14:59 +03:00
|
|
|
public enum Type
|
2018-09-17 10:07:32 +03:00
|
|
|
{
|
|
|
|
LTS,
|
|
|
|
STABLE,
|
|
|
|
BETA,
|
|
|
|
ALPHA,
|
|
|
|
DEV,
|
|
|
|
EXPERIMENTAL,
|
|
|
|
UNKNOWN
|
|
|
|
}
|
|
|
|
}
|