Class TableSchemaFingerprint

java.lang.Object
com.kingsrook.qqq.backend.core.model.metadata.tables.TableSchemaFingerprint

public final class TableSchemaFingerprint extends Object
A stable SHA-256 fingerprint of the persistent shape of a table, together with the descriptor (canonical JSON) it was computed from. The descriptor covers only what affects stored data: - the table name, primary key field and backend type; - each field's name, type, isRequired, maxLength, possible-value-source name, isHeavy and isSensitive (sorted by field name); - the unique keys (field names sorted within a key, keys sorted) and associations (sorted by name). Labels, adornments, help text and other cosmetic metadata are left out on purpose, so changing them does not change the fingerprint. Field order does not matter either. Use SchemaDiff to see what changed between two fingerprints.
  • Method Details

    • of

      public static TableSchemaFingerprint of(QTableMetaData table)
      Fingerprint a table. The backend type comes from the table's backend in the current QContext instance, when there is one - else from the table's backend details - else is empty. Use the 2-arg overload to be explicit.
    • of

      public static TableSchemaFingerprint of(QTableMetaData table, String backendType)
      Fingerprint a table, with an explicit backend type.
    • fromDescriptorJson

      public static TableSchemaFingerprint fromDescriptorJson(String json)
      Rebuild a fingerprint from a stored descriptor (as returned by getDescriptorJson), e.g., one saved in a backup manifest. The JSON is re-canonicalized, so the hash is the same as the original's.
    • getHash

      public String getHash()
      The SHA-256 of the canonical descriptor JSON, as lower-case hex.
    • getDescriptorJson

      public String getDescriptorJson()
      The canonical JSON the hash was computed from: sorted keys, no whitespace.
    • getDescriptor

      public Map<String,Object> getDescriptor()
      The descriptor as maps and lists (a fresh copy on each call).
    • equals

      public boolean equals(Object o)
      Fingerprints are equal when their hashes are.
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object