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

com.hedera.hapi.node.consensus.ConsensusDeleteTopicTransactionBody Maven / Gradle / Ivy

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

import 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;

/**
 * See [ConsensusService.deleteTopic()](#proto.ConsensusService)
 *
 * @param topicID (1) Topic identifier
 */
public record ConsensusDeleteTopicTransactionBody(
    @Nullable TopicID topicID
) {
    /** Protobuf codec for reading and writing in protobuf format */
    public static final Codec PROTOBUF = new com.hedera.hapi.node.consensus.codec.ConsensusDeleteTopicTransactionBodyProtoCodec();
    /** JSON codec for reading and writing in JSON format */
    public static final JsonCodec JSON = new com.hedera.hapi.node.consensus.codec.ConsensusDeleteTopicTransactionBodyJsonCodec();
    
    /** Default instance with all fields set to default values */
    public static final ConsensusDeleteTopicTransactionBody DEFAULT = newBuilder().build();
    /**
     * Create a pre-populated ConsensusDeleteTopicTransactionBody.
     * 
     * @param topicID (1) Topic identifier
     */
    public ConsensusDeleteTopicTransactionBody(TopicID topicID) {
        this.topicID = topicID;
    }
    /**
    * Override the default hashCode method for
    * all other objects to make hashCode
    */
    @Override
    public int hashCode() {
    	int result = 1;
        if (topicID != null && !topicID.equals(DEFAULT.topicID)) {
           result = 31 * result + topicID.hashCode();
        }
    	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;
        }
        ConsensusDeleteTopicTransactionBody thatObj = (ConsensusDeleteTopicTransactionBody)that;
        if (topicID == null && thatObj.topicID != null) {
            return false;
        }
        if (topicID != null && !topicID.equals(thatObj.topicID)) {
            return false;
        }
        return true;
    }
    /**
     * Convenience method to check if the topicID has a value
     *
     * @return true of the topicID has a value
     */
    public boolean hasTopicID() {
    	return topicID != null;
    }
    
    /**
     * Gets the value for topicID if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if topicID is null
     * @return the value for topicID if it has a value, or else returns the default value
     */
    public TopicID topicIDOrElse(@NonNull final TopicID defaultValue) {
    	return hasTopicID() ? topicID : defaultValue;
    }
    
    /**
     * Gets the value for topicID if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for topicID if it has a value
     * @throws NullPointerException if topicID is null
     */
    public @NonNull TopicID topicIDOrThrow() {
    	return requireNonNull(topicID, "Field topicID is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the topicID has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifTopicID(@NonNull final Consumer ifPresent) {
    	if (hasTopicID()) {
    		ifPresent.accept(topicID);
    	}
    }


    /**
     * 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(topicID);
    }
    
    /**
     * 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 {
        @Nullable private TopicID topicID = null;
    
        /**
         * Create an empty builder
         */
        public Builder() {}
    
            /**
         * Create a pre-populated Builder.
         * 
         * @param topicID (1) Topic identifier
         */
        public Builder(TopicID topicID) {
            this.topicID = topicID;
        }
    
    
        /**
         * Build a new model record with data set on builder
         *
         * @return new model record with data set
         */
        public ConsensusDeleteTopicTransactionBody build() {
            return new ConsensusDeleteTopicTransactionBody(topicID);
        }
    
            /**
         * (1) Topic identifier
         *
         * @param topicID value to set
         * @return builder to continue building with
         */
        public Builder topicID(@Nullable TopicID topicID) {
            this.topicID = topicID;
            return this;
        }
    
        /**
         * (1) Topic identifier
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder topicID(TopicID.Builder builder) {
            this.topicID = builder.build() ;
            return this;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy