[fixes #825] Change UpdateInfo
Crap, forgot about this one, should've committed this earlier
This commit is contained in:
parent
ceb8f9482e
commit
ec3b253fb2
@ -1,6 +1,7 @@
|
||||
package net.sf.openrocket.communication;
|
||||
|
||||
import net.sf.openrocket.util.BuildProperties;
|
||||
import net.sf.openrocket.communication.UpdateInfoRetriever.ReleaseStatus;
|
||||
import net.sf.openrocket.communication.UpdateInfoRetriever.UpdateInfoFetcher.UpdateCheckerException;
|
||||
|
||||
/**
|
||||
* Class that stores the update information of the application
|
||||
@ -8,37 +9,37 @@ import net.sf.openrocket.util.BuildProperties;
|
||||
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||
*/
|
||||
public class UpdateInfo {
|
||||
private final String latestVersion;
|
||||
|
||||
// Release info of the latest release. If null, the current build is the latest version
|
||||
private final ReleaseInfo latestRelease;
|
||||
private final ReleaseStatus releaseStatus;
|
||||
private final UpdateCheckerException exception; // Exception that was thrown during the release fetching process. If null, the fetching was successful.
|
||||
|
||||
/**
|
||||
* loads the default information
|
||||
* Constructor for when a valid release is found.
|
||||
* @param latestRelease the release info object of the latest GitHub release
|
||||
* @param releaseStatus the release status of the current build version compared to the latest GitHub release version
|
||||
*/
|
||||
public UpdateInfo() {
|
||||
this.latestVersion = BuildProperties.getVersion();
|
||||
this.latestRelease = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* loads a custom update information into the cache
|
||||
* @param latestRelease The release info object of the latest GitHub release
|
||||
*/
|
||||
public UpdateInfo(ReleaseInfo latestRelease) {
|
||||
public UpdateInfo(ReleaseInfo latestRelease, ReleaseStatus releaseStatus) {
|
||||
this.latestRelease = latestRelease;
|
||||
this.latestVersion = latestRelease.getReleaseTag();
|
||||
this.releaseStatus = releaseStatus;
|
||||
this.exception = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for when an error occurred when checking the latest release.
|
||||
* @param exception exception that was thrown when checking the releases
|
||||
*/
|
||||
public UpdateInfo(UpdateCheckerException exception) {
|
||||
this.latestRelease = null;
|
||||
this.releaseStatus = null;
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest OpenRocket version. If it is the current version, then the value
|
||||
* of {@link BuildProperties#getVersion()} is returned.
|
||||
*
|
||||
* @return the latest OpenRocket version.
|
||||
* Get the release status of the current build version compared to the latest GitHub release version.
|
||||
* @return the release status of the current
|
||||
*/
|
||||
public String getLatestVersion() {
|
||||
return latestVersion;
|
||||
public ReleaseStatus getReleaseStatus() {
|
||||
return this.releaseStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,12 +47,19 @@ public class UpdateInfo {
|
||||
* @return the latest GitHub release object
|
||||
*/
|
||||
public ReleaseInfo getLatestRelease() {
|
||||
return latestRelease;
|
||||
return this.latestRelease;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the exception that was thrown when fetching the latest release. If the fetching was successful, null is returned.
|
||||
* @return UpdateCheckerException exception that was thrown when fetching the release. Null if fetching was successful
|
||||
*/
|
||||
public UpdateCheckerException getException() {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UpdateInfo[version=" + latestVersion + "; latestRelease=" + latestRelease.toString() + "]";
|
||||
return "UpdateInfo[releaseStatus=" + releaseStatus + "; latestRelease=" + (latestRelease == null ? "null" : latestRelease.toString()) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user