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

com.hedera.hapi.node.base.ScheduleID Maven / Gradle / Ivy

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

import com.hedera.pbj.runtime.*;
import com.hedera.pbj.runtime.io.*;
import com.hedera.pbj.runtime.io.buffer.*;
import com.hedera.pbj.runtime.io.stream.*;
import edu.umd.cs.findbugs.annotations.*;

import com.hedera.pbj.runtime.Codec;
import java.util.function.Consumer;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.NonNull;
import static java.util.Objects.requireNonNull;

/**
 * Unique identifier for a Schedule
 *
 * @param shardNum (1) A nonnegative shard number
 * @param realmNum (2) A nonnegative realm number
 * @param scheduleNum (3) A nonnegative schedule number
 */
public record ScheduleID(
    long shardNum,
    long realmNum,
    long scheduleNum
) {
    /** Protobuf codec for reading and writing in protobuf format */
    public static final Codec PROTOBUF = new com.hedera.hapi.node.base.codec.ScheduleIDProtoCodec();
    /** JSON codec for reading and writing in JSON format */
    public static final JsonCodec JSON = new com.hedera.hapi.node.base.codec.ScheduleIDJsonCodec();
    
    /** Default instance with all fields set to default values */
    public static final ScheduleID DEFAULT = newBuilder().build();
    /**
     * Create a pre-populated ScheduleID.
     * 
     * @param shardNum (1) A nonnegative shard number, 
     * @param realmNum (2) A nonnegative realm number, 
     * @param scheduleNum (3) A nonnegative schedule number
     */
    public ScheduleID(long shardNum, long realmNum, long scheduleNum) {
        this.shardNum = shardNum;
        this.realmNum = realmNum;
        this.scheduleNum = scheduleNum;
    }
    /**
    * Override the default hashCode method for
    * all other objects to make hashCode
    */
    @Override
    public int hashCode() {
    	int result = 1;
        if (shardNum != DEFAULT.shardNum) {
            result = 31 * result + Long.hashCode(shardNum);
        }
        if (realmNum != DEFAULT.realmNum) {
            result = 31 * result + Long.hashCode(realmNum);
        }
        if (scheduleNum != DEFAULT.scheduleNum) {
            result = 31 * result + Long.hashCode(scheduleNum);
        }
    	long hashCode = result;
        // Shifts: 30, 27, 16, 20, 5, 18, 10, 24, 30
        hashCode += hashCode << 30;
        hashCode ^= hashCode >>> 27;
        hashCode += hashCode << 16;
        hashCode ^= hashCode >>> 20;
        hashCode += hashCode << 5;
        hashCode ^= hashCode >>> 18;
        hashCode += hashCode << 10;
        hashCode ^= hashCode >>> 24;
        hashCode += hashCode << 30;
    
    	return (int)hashCode;
    }
    /**
    * Override the default equals method for
    */
    @Override
    public boolean equals(Object that) {
        if (that == null || this.getClass() != that.getClass()) {
            return false;
        }
        ScheduleID thatObj = (ScheduleID)that;
        if (shardNum != thatObj.shardNum) {
            return false;
        }
        if (realmNum != thatObj.realmNum) {
            return false;
        }
        if (scheduleNum != thatObj.scheduleNum) {
            return false;
        }
        return true;
    }


    /**
     * Return a builder for building a copy of this model object. It will be pre-populated with all the data from this
     * model object.
     *
     * @return a pre-populated builder
     */
    public Builder copyBuilder() {
        return new Builder(shardNum, realmNum, scheduleNum);
    }
    
    /**
     * Return a new builder for building a model object. This is just a shortcut for new Model.Builder().
     *
     * @return a new builder
     */
    public static Builder newBuilder() {
        return new Builder();
    }
    /**
     * Builder class for easy creation, ideal for clean code where performance is not critical. In critical performance
     * paths use the constructor directly.
     */
    public static final class Builder {
        private long shardNum = 0;
        private long realmNum = 0;
        private long scheduleNum = 0;
    
        /**
         * Create an empty builder
         */
        public Builder() {}
    
            /**
         * Create a pre-populated Builder.
         * 
         * @param shardNum (1) A nonnegative shard number, 
         * @param realmNum (2) A nonnegative realm number, 
         * @param scheduleNum (3) A nonnegative schedule number
         */
        public Builder(long shardNum, long realmNum, long scheduleNum) {
            this.shardNum = shardNum;
            this.realmNum = realmNum;
            this.scheduleNum = scheduleNum;
        }
    
    
        /**
         * Build a new model record with data set on builder
         *
         * @return new model record with data set
         */
        public ScheduleID build() {
            return new ScheduleID(shardNum, realmNum, scheduleNum);
        }
    
            /**
         * (1) A nonnegative shard number
         *
         * @param shardNum value to set
         * @return builder to continue building with
         */
        public Builder shardNum(long shardNum) {
            this.shardNum = shardNum;
            return this;
        }
    
        /**
         * (2) A nonnegative realm number
         *
         * @param realmNum value to set
         * @return builder to continue building with
         */
        public Builder realmNum(long realmNum) {
            this.realmNum = realmNum;
            return this;
        }
    
        /**
         * (3) A nonnegative schedule number
         *
         * @param scheduleNum value to set
         * @return builder to continue building with
         */
        public Builder scheduleNum(long scheduleNum) {
            this.scheduleNum = scheduleNum;
            return this;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy