Skip to content
Snippets Groups Projects
Verified Commit 9af7137a authored by Griefed's avatar Griefed :joystick:
Browse files

docs(Examples): Provide an example for the usage of the new Update-object in...

docs(Examples): Provide an example for the usage of the new Update-object in the README and expand sourceTar and sourceTarBz2 methods descriptions on when they are available.
parent 622a2897
No related branches found
No related tags found
No related merge requests found
......@@ -61,10 +61,54 @@ implementation 'de.griefed:versionchecker:$VERSION'
For available versions, see the [sonatype repo](https://search.maven.org/artifact/de.griefed/versionchecker/)
# Example
# Examples
See [UpdateCheckerTests](src/test/java/de/griefed/versionchecker/UpdateCheckerTests.java)
The simplest way to acquire update information is to call `.check(...)` of your GitHub- or GitHubChecker instances with your current version.
This will return an instance of [Update](https://github.com/Griefed/VersionChecker/blob/main/src/main/java/de/griefed/versionchecker/Update.java) which contains
details about the available update. It is wrapped in an Optional, so you can conveniently check via `.isPresent()` if an update is available.
Once an instance of [Update](https://github.com/Griefed/VersionChecker/blob/main/src/main/java/de/griefed/versionchecker/Update.java) has been retrieved,
you can access information about it via any of the available methods.
Example:
```java
GitHubChecker GITHUB = new GitHubChecker("Griefed/ServerPackCreator");
Optional<Update> gitHubUpdate = GITHUB.check("3.0.1",false);
if (gitHubUpdate.isPresent()) {
// Gets the version of this update as a String.
gitHubUpdate.get().version();
// Check whether the update has a description
if (gitHubUpdate.get().description().isPresent()) {
// Get the description
gitHubUpdate.get().description().get();
}
// Get the url to the release page of this update
gitHubUpdate.get().url();
// Get the date at which this update has been released.
gitHubUpdate.get().releaseDate();
// Check if the update has any assets attached to it
if (gitHubUpdate.get().assets().isPresent()) {
// Get the available assets of this update
gitHubUpdate.get().assets().get();
}
// Get the available source-archives of this update
gitHubUpdate.get().sources();
}
```
```java
public class UpdateChecker {
......
......@@ -146,9 +146,9 @@ public class Update {
}
/**
* Get the ZIP-archive-source of this update.
* Get the tar.gz-archive-source of this update.
* @author Griefed
* @return {@link Source} of {@link ArchiveType#ZIP} of this update.
* @return {@link Source} of {@link ArchiveType#TAR_GZ} of this update.
*/
public Source sourceTarGz() {
for (Source source : SOURCES) {
......@@ -160,9 +160,10 @@ public class Update {
}
/**
* Get the ZIP-archive-source of this update.
* Get the tar-archive-source of this update. A tar-archive is usually only available for GitLab updates. GitHub typically
* only provides zip- and tar.gz-archives.
* @author Griefed
* @return {@link Source} of {@link ArchiveType#ZIP} of this update, wrapped in an {@link Optional}.
* @return {@link Source} of {@link ArchiveType#TAR} of this update, wrapped in an {@link Optional}.
*/
public Optional<Source> sourceTar() {
for (Source source : SOURCES) {
......@@ -174,9 +175,10 @@ public class Update {
}
/**
* Get the ZIP-archive-source of this update.
* Get the tar.bz2-archive-source of this update. A tar.bz2-archive is usually only available for GitLab updates. GitHub typically
* only provides zip- and tar.gz-archives.
* @author Griefed
* @return {@link Source} of {@link ArchiveType#ZIP} of this update, wrapped in an {@link Optional}.
* @return {@link Source} of {@link ArchiveType#TAR_BZ2} of this update, wrapped in an {@link Optional}.
*/
public Optional<Source> sourceTarBz2() {
for (Source source : SOURCES) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment