com.hedera.hapi.node.token.schema.CryptoGetLiveHashQuerySchema Maven / Gradle / Ivy
package com.hedera.hapi.node.token.schema;
import com.hedera.pbj.runtime.FieldDefinition;
import com.hedera.pbj.runtime.FieldType;
import com.hedera.pbj.runtime.Schema;
/**
* Schema for CryptoGetLiveHashQuery model object. Generate based on protobuf schema.
*/
public final class CryptoGetLiveHashQuerySchema implements Schema {
// -- FIELD DEFINITIONS ---------------------------------------------
/**
* (1) Standard info sent from client to node, including the signed payment, and what kind of
* response is requested (cost, state proof, both, or neither).
*/
public static final FieldDefinition HEADER = new FieldDefinition("header", FieldType.MESSAGE, false, false, false, 1);
/**
* (2) The account to which the livehash is associated
*/
public static final FieldDefinition ACCOUNT_ID = new FieldDefinition("accountID", FieldType.MESSAGE, false, false, false, 2);
/**
* (3) The SHA-384 data in the livehash
*/
public static final FieldDefinition HASH = new FieldDefinition("hash", FieldType.BYTES, false, false, false, 3);
// -- OTHER METHODS -------------------------------------------------
/**
* Check if a field definition belongs to this schema.
*
* @param f field def to check
* @return true if it belongs to this schema
*/
public static boolean valid(FieldDefinition f) {
return f != null && getField(f.number()) == f;
}
/**
* Get a field definition given a field number
*
* @param fieldNumber the fields number to get def for
* @return field def or null if field number does not exist
*/
public static FieldDefinition getField(final int fieldNumber) {
return switch(fieldNumber) {
case 1 -> HEADER;
case 2 -> ACCOUNT_ID;
case 3 -> HASH;
default -> null;
};
}
}