Class AppExtensionInfo

java.lang.Object
ca.corbett.extensions.AppExtensionInfo

public class AppExtensionInfo extends Object
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
  • Field Details

    • gson

      protected static com.google.gson.Gson gson
    • name

      protected final String name
    • version

      protected final String version
    • targetAppName

      protected final String targetAppName
    • targetAppVersion

      protected final String targetAppVersion
    • author

      protected final String author
    • releaseNotes

      protected final String releaseNotes
    • shortDescription

      protected final String shortDescription
    • longDescription

      protected final String longDescription
    • customFields

      protected final Map<String,String> customFields
  • Constructor Details

  • Method Details

    • toJson

      public String toJson()
    • fromJson

      public static AppExtensionInfo fromJson(String json)
      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

      public static AppExtensionInfo fromStream(InputStream stream)
      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

      public String getName()
    • getAuthor

      public String getAuthor()
    • getVersion

      public String getVersion()
    • getTargetAppName

      public String getTargetAppName()
    • getTargetAppVersion

      public String getTargetAppVersion()
    • getShortDescription

      public String getShortDescription()
    • getLongDescription

      public String getLongDescription()
    • getReleaseNotes

      public String getReleaseNotes()
    • getCustomFieldNames

      public List<String> getCustomFieldNames()
    • getCustomFieldValue

      public String getCustomFieldValue(String fieldName)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getGson

      protected static com.google.gson.Gson getGson()