[fixes #825] Change UpdateInfo with ReleaseInfo information

This commit is contained in:
Sibo Van Gool 2022-01-21 23:26:28 +01:00
parent 33e5e6ce61
commit fa5677727e

View File

@ -1,42 +1,36 @@
package net.sf.openrocket.communication; package net.sf.openrocket.communication;
import java.util.List;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.BuildProperties; import net.sf.openrocket.util.BuildProperties;
import net.sf.openrocket.util.ComparablePair;
/** /**
* Class that stores the update information of the application
* *
* class that stores the update information of the application * @author Sibo Van Gool <sibo.vangool@hotmail.com>
*
*/ */
public class UpdateInfo { public class UpdateInfo {
private final String latestVersion; private final String latestVersion;
private final ArrayList<ComparablePair<Integer, String>> updates; // Release info of the latest release. If null, the current build is the latest version
private final ReleaseInfo latestRelease;
/** /**
* loads the default information * loads the default information
*/ */
public UpdateInfo() { public UpdateInfo() {
this.latestVersion = BuildProperties.getVersion(); this.latestVersion = BuildProperties.getVersion();
this.updates = new ArrayList<ComparablePair<Integer, String>>(); this.latestRelease = null;
} }
/** /**
* loads a custom update information into the cache * loads a custom update information into the cache
* @param version String with the version * @param latestRelease The release info object of the latest GitHub release
* @param updates The list of updates contained in the version
*/ */
public UpdateInfo(String version, List<ComparablePair<Integer, String>> updates) { public UpdateInfo(ReleaseInfo latestRelease) {
this.latestVersion = version; this.latestRelease = latestRelease;
this.updates = new ArrayList<ComparablePair<Integer, String>>(updates); this.latestVersion = latestRelease.getReleaseTag();
} }
/** /**
* Get the latest OpenRocket version. If it is the current version, then the value * Get the latest OpenRocket version. If it is the current version, then the value
* of {@link BuildProperties#getVersion()} is returned. * of {@link BuildProperties#getVersion()} is returned.
@ -47,20 +41,17 @@ public class UpdateInfo {
return latestVersion; return latestVersion;
} }
/** /**
* Return a list of the new features/updates that are available. The list has a * Get the latest release info object.
* priority for each update and a message text. The returned list may be modified. * @return the latest GitHub release object
*
* @return a modifiable list of the updates.
*/ */
public List<ComparablePair<Integer, String>> getUpdates() { public ReleaseInfo getLatestRelease() {
return updates.clone(); return latestRelease;
} }
@Override @Override
public String toString() { public String toString() {
return "UpdateInfo[version=" + latestVersion + "; updates=" + updates.toString() + "]"; return "UpdateInfo[version=" + latestVersion + "; latestRelease=" + latestRelease.toString() + "]";
} }
} }