[fixes #825] Change UpdateInfo

Crap, forgot about this one, should've committed this earlier
This commit is contained in:
Sibo Van Gool 2022-01-26 03:07:50 +01:00
parent ceb8f9482e
commit ec3b253fb2

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.communication; 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 * 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> * @author Sibo Van Gool <sibo.vangool@hotmail.com>
*/ */
public class UpdateInfo { 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 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() { public UpdateInfo(ReleaseInfo latestRelease, ReleaseStatus releaseStatus) {
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) {
this.latestRelease = latestRelease; 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 * Get the release status of the current build version compared to the latest GitHub release version.
* of {@link BuildProperties#getVersion()} is returned. * @return the release status of the current
*
* @return the latest OpenRocket version.
*/ */
public String getLatestVersion() { public ReleaseStatus getReleaseStatus() {
return latestVersion; return this.releaseStatus;
} }
/** /**
@ -46,12 +47,19 @@ public class UpdateInfo {
* @return the latest GitHub release object * @return the latest GitHub release object
*/ */
public ReleaseInfo getLatestRelease() { 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 @Override
public String toString() { public String toString() {
return "UpdateInfo[version=" + latestVersion + "; latestRelease=" + latestRelease.toString() + "]"; return "UpdateInfo[releaseStatus=" + releaseStatus + "; latestRelease=" + (latestRelease == null ? "null" : latestRelease.toString()) + "]";
} }
} }