com.hedera.hapi.node.base.schema.NftIDSchema Maven / Gradle / Ivy
The newest version!
package com.hedera.hapi.node.base.schema;
import com.hedera.pbj.runtime.FieldDefinition;
import com.hedera.pbj.runtime.FieldType;
import com.hedera.pbj.runtime.Schema;
/**
* Schema for NftID model object. Generate based on protobuf schema.
*/
public final class NftIDSchema implements Schema {
// -- FIELD DEFINITIONS ---------------------------------------------
/**
* (1) The (non-fungible) token of which this NFT is an instance; uppercase for "ID"
* for backward compatibility with original definition of this field.
*/
public static final FieldDefinition TOKEN_ID = new FieldDefinition("token_ID", FieldType.MESSAGE, false, false, false, 1);
/**
* (2) The serial number of this NFT within its token type
*/
public static final FieldDefinition SERIAL_NUMBER = new FieldDefinition("serial_number", FieldType.INT64, false, false, false, 2);
// -- 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 -> TOKEN_ID;
case 2 -> SERIAL_NUMBER;
default -> null;
};
}
}