Class InstanceId

java.lang.Object
dev.getelements.elements.sdk.cluster.id.InstanceId
All Implemented Interfaces:
Serializable, Comparable<dev.getelements.elements.sdk.cluster.id.HasCompoundId<dev.getelements.elements.sdk.cluster.id.V1CompoundId>>

public class InstanceId extends Object implements Serializable
Represents an ID for an instance.
See Also:
  • Constructor Details

    • InstanceId

      public InstanceId(String stringRepresentation)
    • InstanceId

      public InstanceId(byte[] byteRepresentation)
    • InstanceId

      public InstanceId(UUID instanceUuid)
  • Method Details

    • getUuid

      public UUID getUuid()
      Gets a UUID representing the instance id.
      Returns:
      the UUID of this InstanceId
    • asString

      public String asString()
      Returns the compound Id string representation of this NodeId
      Returns:
      the string representation
    • asBytes

      public byte[] asBytes()
    • getId

      public dev.getelements.elements.sdk.cluster.id.V1CompoundId getId()
    • equals

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

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

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

      public static InstanceId valueOf(String value)
      The Java standard valueOf method.
      Parameters:
      value - the value
      Returns:
      the InstanceId
    • randomInstanceId

      public static InstanceId randomInstanceId()
      Generates a randomly-assigned unique InstanceId.
      Returns:
      the generated InstanceId
    • forUniqueName

      public static InstanceId forUniqueName(String uniqueInstanceName)
      Creates a new InstanceId from the given unique instance name. The unique instance name may be any string uniquely representing the instance (such as database primary key, DNS hostname) or similar.
      Parameters:
      uniqueInstanceName - the unique instance name
      Returns:
      the newly created InstanceId
    • loadOrGenerate

      public static InstanceId loadOrGenerate(String path)
      Creates a file on disk at the supplied path to hold an InstanceId. A file already exists at at that location and it is a valid instance ID, it will simply return that value read from disk.
      Parameters:
      path - the path to the instance ID file
      Returns:
      the InstanceId read or generated
    • loadOrGenerate

      public static InstanceId loadOrGenerate(File file)
      Creates a file on disk at the supplied path to hold an InstanceId. A file already exists at at that location and it is a valid instance ID, it will simply return that value read from disk.
      Parameters:
      file - the path to the instance ID file
      Returns:
      the InstanceId read or generated
    • compareTo

      default int compareTo(dev.getelements.elements.sdk.cluster.id.HasCompoundId<dev.getelements.elements.sdk.cluster.id.V1CompoundId> o)
      Compares this instance with the other instance.
      Specified by:
      compareTo in interface Comparable<CompoundIdT extends Comparable<CompoundIdT>>
      Parameters:
      o - the instance
      Returns: