All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.datahubproject.models.util.DataHubKey Maven / Gradle / Ivy

There is a newer version: 0.15.0rc25
Show newest version
package io.datahubproject.models.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import lombok.Data;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class DataHubKey {
  // Static ObjectMapper instance since it's thread-safe and expensive to create
  protected static final ObjectMapper MAPPER = new ObjectMapper();
  // Static TypeReference instance since it doesn't change
  private static final TypeReference> MAP_TYPE_REFERENCE =
      new TypeReference>() {};

  static {
    MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  }

  public Map guidDict() {
    return MAPPER.convertValue(this, MAP_TYPE_REFERENCE);
  }

  public String guid() {
    Map bag = guidDict();
    return DataHubGuidGenerator.dataHubGuid(bag);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy