Class Library

java.lang.Object
net.glowstone.util.library.Library
All Implemented Interfaces:
Comparable<Library>

public class Library extends Object implements Comparable<Library>
Represents a library that will be injected into the classpath at runtime.
  • Constructor Details

    • Library

      public Library(String groupId, String artifactId, String version)
      Creates a Library instance with the specified group ID, artifact ID, and version.
      Parameters:
      groupId - The group ID of the library, separated by periods.
      artifactId - The artifact ID of the library.
      version - The version of the library.
    • Library

      public Library(String groupId, String artifactId, String version, String repository)
      Creates a Library instance with the specified group ID, artifact ID, version, and repository.
      Parameters:
      groupId - The group ID of the library, separated by periods.
      artifactId - The artifact ID of the library.
      version - The version of the library.
      repository - The URL of the library's repository.
    • Library

      public Library(@NonNls @NonNls String groupId, @NonNls @NonNls String artifactId, @NonNls @NonNls String version, LibraryManager.HashAlgorithm checksumType, @NonNls @NonNls String checksumValue)
      Creates a Library instance with the specified group ID, artifact ID, version, and checksum.
      Parameters:
      groupId - The group ID of the library, separated by periods.
      artifactId - The artifact ID of the library.
      version - The version of the library.
      checksumType - The type of hash the checksum is using.
      checksumValue - The checksum to validate the downloaded library against.
    • Library

      public Library(String groupId, String artifactId, String version, String repository, LibraryManager.HashAlgorithm checksumType, String checksumValue, boolean excludeDependencies)
      Creates a Library instance with the specified group ID, artifact ID, version, repository, and checksum.
      Parameters:
      groupId - The group ID of the library, separated by periods.
      artifactId - The artifact ID of the library.
      version - The version of the library.
      repository - The URL of the library's repository.
      checksumType - The type of hash the checksum is using.
      checksumValue - The checksum to validate the downloaded library against.
      excludeDependencies - Specifies that dependencies may be excluded.
  • Method Details

    • fromConfigMap

      public static Library fromConfigMap(Map<?,?> configMap)
      Extracts the needed information from a map of key-value pairs inside a config file to download a Library and inject it at runtime.
      Parameters:
      configMap - The Map that was extracted from a config file.
      Returns:
      A Library instance populated with whatever information we could extract.
    • toConfigMap

      public Map<?,?> toConfigMap()
      Converts the Library instance to a map that can be serialized and saved into a config file.
      Returns:
      A map that is able to be serialized into a config.
    • getGroupId

      public String getGroupId()
      Returns the group ID of this library.
    • getArtifactId

      public String getArtifactId()
      Returns the artifact ID of this library.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public int compareTo(Library o)
      Specified by:
      compareTo in interface Comparable<Library>
    • getLibraryKey

      public LibraryKey getLibraryKey()
      The group ID of the library in a maven-style repo. Parts of the group ID must be separated by periods.
    • getVersion

      public String getVersion()
      The version number of the library in a maven-style repo.
    • getRepository

      public String getRepository()
      The optional URL for this library, for use in cases where the library is not part of the default Maven repo.
    • getChecksumType

      public LibraryManager.HashAlgorithm getChecksumType()
      The algorithm used to generate the checksum for this library, if one was specified.
    • getChecksumValue

      public String getChecksumValue()
      The checksum itself, validated against the library to make sure the library is intact.
    • isExcludeDependencies

      public boolean isExcludeDependencies()
      Excludes the dependency from any dependency checks. Use this if the library is locally hosted.