Package ca.corbett.extensions
Class AppExtensionInfo
java.lang.Object
ca.corbett.extensions.AppExtensionInfo
Allows an extension to provide some basic metadata about itself.
Name, version, targetAppName, and targetAppVersion should be considered
mandatory, with the remaining fields being optional. Extra application-specific
fields can be thrown into the custom field map, but you are restricted
to simple single-line string values. Every extension should package
an extInfo.json file as a resource into its jar file so that it can
be discovered and interrogated by ExtensionManager. See ExtensionManager.extractExtInfo()
for more.
- Since:
- 2023-11-11
- Author:
- scorbo2
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic AppExtensionInfofromExtensionJar(Class<? extends AppExtension> extensionClass, String resource) Attempts to use the given Class to read extInfo from the given jar resource.static AppExtensionInfoAttempts to parse an AppExtensionInfo out of the given json.static AppExtensionInfofromStream(InputStream stream) Attempts to parse an AppExtensionInfo instance out of json read from the given InputStream.getCustomFieldValue(String fieldName) protected static com.google.gson.GsongetGson()getName()inthashCode()toJson()
-
Field Details
-
gson
protected static com.google.gson.Gson gson -
name
-
version
-
targetAppName
-
targetAppVersion
-
author
-
releaseNotes
-
shortDescription
-
longDescription
-
customFields
-
-
Constructor Details
-
AppExtensionInfo
-
-
Method Details
-
toJson
-
fromJson
Attempts to parse an AppExtensionInfo out of the given json. Any field not mentioned in the json will be returned as null.- Parameters:
json- A json representation of an AppExtensionInfo object.- Returns:
- An AppExtensionInfo object, or null if parsing was not possible.
-
fromStream
Attempts to parse an AppExtensionInfo instance out of json read from the given InputStream. Example usage in an extension:AppExtensionInfo.fromStream(this.getClass().getClassLoader().getResourceAsStream("/path/extInfo.json"));- Parameters:
stream- An InputStream containing json.- Returns:
- An AppExtensionInfo object, or null if parsing was not possible.
-
fromExtensionJar
public static AppExtensionInfo fromExtensionJar(Class<? extends AppExtension> extensionClass, String resource) Attempts to use the given Class to read extInfo from the given jar resource. This is intended to be invoked by extension jars, where resources have to be loaded from the class that is present in the jar that contains them.- Parameters:
extensionClass- the extension class responsible for loading the resource.resource- the jar resource to be loaded (full resource path and name of extInfo.json)- Returns:
- A parsed AppExtensionInfo object, or null if the resource could not be read.
-
getName
-
getAuthor
-
getVersion
-
getTargetAppName
-
getTargetAppVersion
-
getShortDescription
-
getLongDescription
-
getReleaseNotes
-
getCustomFieldNames
-
getCustomFieldValue
-
hashCode
public int hashCode() -
equals
-
getGson
protected static com.google.gson.Gson getGson()
-