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

com.hedera.hapi.node.file.schema.FileInfoSchema Maven / Gradle / Ivy

There is a newer version: 0.54.0
Show newest version
package com.hedera.hapi.node.file.schema;

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


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

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

    /**
     * (1) The file ID of the file for which information is requested
     */
    public static final FieldDefinition FILE_ID = new FieldDefinition("fileID", FieldType.MESSAGE, false, false, false, 1);


    /**
     * (2) Number of bytes in contents
     */
    public static final FieldDefinition SIZE = new FieldDefinition("size", FieldType.INT64, false, false, false, 2);


    /**
     * (3) The current time at which this account is set to expire
     */
    public static final FieldDefinition EXPIRATION_TIME = new FieldDefinition("expirationTime", FieldType.MESSAGE, false, false, false, 3);


    /**
     * (4) True if deleted but not yet expired
     */
    public static final FieldDefinition DELETED = new FieldDefinition("deleted", FieldType.BOOL, false, false, false, 4);


    /**
     * (5) One of these keys must sign in order to modify or delete the file
     */
    public static final FieldDefinition KEYS = new FieldDefinition("keys", FieldType.MESSAGE, false, false, false, 5);


    /**
     * (6) The memo associated with the file
     */
    public static final FieldDefinition MEMO = new FieldDefinition("memo", FieldType.STRING, false, false, false, 6);


    /**
     * (7) The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs.
     */
    public static final FieldDefinition LEDGER_ID = new FieldDefinition("ledger_id", FieldType.BYTES, false, false, false, 7);


    // -- 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 -> FILE_ID;
            case 2 -> SIZE;
            case 3 -> EXPIRATION_TIME;
            case 4 -> DELETED;
            case 5 -> KEYS;
            case 6 -> MEMO;
            case 7 -> LEDGER_ID;
	        default -> null;
	    };
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy