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

com.hedera.hapi.node.transaction.schema.EntityIDSchema Maven / Gradle / Ivy

The newest version!
package com.hedera.hapi.node.transaction.schema;

import com.hedera.pbj.runtime.FieldDefinition;
import com.hedera.pbj.runtime.FieldType;
import com.hedera.pbj.runtime.Schema;

import com.hedera.hapi.node.base.*;
import com.hedera.hapi.node.token.*;
import com.hedera.pbj.runtime.*;


/**
 * Schema for EntityID model object. Generate based on protobuf schema.
 */
public final class EntityIDSchema implements Schema {

    // -- FIELD DEFINITIONS ---------------------------------------------

    /**
     * (1) The Account ID for the cryptocurrency account
     */
    public static final FieldDefinition ACCOUNT_ID = new FieldDefinition("accountID", FieldType.MESSAGE, false, false, true, 1);

    /**
     * (2) A uniquely identifying livehash of an acount
     */
    public static final FieldDefinition LIVE_HASH = new FieldDefinition("liveHash", FieldType.MESSAGE, false, false, true, 2);

    /**
     * (3) The file ID of the file
     */
    public static final FieldDefinition FILE_ID = new FieldDefinition("fileID", FieldType.MESSAGE, false, false, true, 3);

    /**
     * (4) The smart contract ID that identifies instance
     */
    public static final FieldDefinition CONTRACT_ID = new FieldDefinition("contractID", FieldType.MESSAGE, false, false, true, 4);


    // -- 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 -> ACCOUNT_ID;
            case 2 -> LIVE_HASH;
            case 3 -> FILE_ID;
            case 4 -> CONTRACT_ID;
	        default -> null;
	    };
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy