Class DatasetKey

java.lang.Object
org.gbif.api.util.DatasetKey

public class DatasetKey extends Object
A typed dataset key for both registered and external datasets. External dataset keys are compound keys based on the originating network UUID key and a free String based local identifier. The compound external datasetKey is structured as follows in its serialized form:
{NETWORK_KEY}:{DATASET_ID}
This class is intended as a utility class, lacks mutability and therefore is not suitable serialization via Jackson!
  • Constructor Details

    • DatasetKey

      public DatasetKey(UUID datasetKey)
      Constructor for a registered dataset key.
    • DatasetKey

      public DatasetKey(UUID networkKey, String datasetId)
      Constructor for an external dataset key.
      Parameters:
      networkKey - of the originating network
      datasetId - the local dataset id within the network
  • Method Details

    • fromString

      public static DatasetKey fromString(String key)
      Parses a datasetKey which can be either a compound external key or a simple UUID for registered datasets.
      Parameters:
      key - a simple registered dataset uuid key or an external compound dataset key
      Returns:
      a valid DatasetKey instance
      Throws:
      IllegalArgumentException - for invalid external or registered dataset keys
    • getRegistryKey

      public UUID getRegistryKey()
      A registered UUID of either a dataset or the network of origin in the case of external datasets.
      Returns:
      the registered network or dataset key
    • getDatasetId

      public String getDatasetId()
      Returns:
      the local identifier of an external dataset key or null if its a registered dataset
    • isExternalKey

      public boolean isExternalKey()
    • toDatasetKey

      public String toDatasetKey()
      Generates the serialized dataset key as used in the Dataset class.
      Returns:
      the serialized dataset key