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

com.hedera.hapi.node.token.AccountInfo Maven / Gradle / Ivy

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

import com.hedera.hapi.node.base.*;
import com.hedera.hapi.node.token.*;
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 java.util.*;

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;

/**
 * AccountInfo
 *
 * @param accountID (1) The account ID for which this information applies
 * @param contractAccountID (2) The Contract Account ID comprising of both the contract instance and the cryptocurrency
 *                          account owned by the contract instance, in the format used by Solidity
 * @param deleted (3) If true, then this account has been deleted, it will disappear when it expires, and all
 *                transactions for it will fail except the transaction to extend its expiration date
 * @param proxyAccountID (4) [Deprecated] The Account ID of the account to which this is proxy staked. If proxyAccountID is null,
 *                       or is an invalid account, or is an account that isn't a node, then this account is
 *                       automatically proxy staked to a node chosen by the network, but without earning payments.
 *                       If the proxyAccountID account refuses to accept proxy staking , or if it is not currently
 *                       running a node, then it will behave as if proxyAccountID was null.
 * @param proxyReceived (6) The total number of tinybars proxy staked to this account
 * @param key (7) The key for the account, which must sign in order to transfer out, or to modify the
 *            account in any way other than extending its expiration date.
 * @param balance (8) The current balance of account in tinybars
 * @param generateSendRecordThreshold (9) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
 *                                    transaction that decreases the balance of this account by more than the threshold
 * @param generateReceiveRecordThreshold (10) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
 *                                       transaction that increases the balance of this account by more than the threshold
 * @param receiverSigRequired (11) If true, no transaction can transfer to this account unless signed by this account's key
 * @param expirationTime (12) The TimeStamp time at which this account is set to expire
 * @param autoRenewPeriod (13) The duration for expiration time will extend every this many seconds. If there are
 *                        insufficient funds, then it extends as long as possible. If it is empty when it expires,
 *                        then it is deleted.
 * @param liveHashes (14) All of the livehashes attached to the account (each of which is a hash along with the
 *                   keys that authorized it and can delete it)
 * @param tokenRelationships (15) [DEPRECATED] The metadata of the tokens associated to the account. This field was 
 *                           deprecated by HIP-367, which allowed 
 *                           an account to be associated to an unlimited number of tokens. This scale makes it more 
 *                           efficient for users to consult mirror nodes to review their token associations.
 * @param memo (16) The memo associated with the account
 * @param ownedNfts (17) The number of NFTs owned by this account
 * @param maxAutomaticTokenAssociations (18) The maximum number of tokens that an Account can be implicitly associated with.
 * @param alias (19) The alias of this account
 * @param ledgerId (20) The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs.
 * @param ethereumNonce (21) The ethereum transaction nonce associated with this account.
 * @param stakingInfo (22) Staking metadata for this account.
 */
public record AccountInfo(
    @Nullable AccountID accountID,
    @NonNull String contractAccountID,
    boolean deleted,
    @Nullable AccountID proxyAccountID,
    long proxyReceived,
    @Nullable Key key,
    long balance,
    long generateSendRecordThreshold,
    long generateReceiveRecordThreshold,
    boolean receiverSigRequired,
    @Nullable Timestamp expirationTime,
    @Nullable Duration autoRenewPeriod,
    @NonNull List liveHashes,
    @NonNull List tokenRelationships,
    @NonNull String memo,
    long ownedNfts,
    int maxAutomaticTokenAssociations,
    @NonNull Bytes alias,
    @NonNull Bytes ledgerId,
    long ethereumNonce,
    @Nullable StakingInfo stakingInfo
) {
    /** Protobuf codec for reading and writing in protobuf format */
    public static final Codec PROTOBUF = new com.hedera.hapi.node.token.codec.AccountInfoProtoCodec();
    /** JSON codec for reading and writing in JSON format */
    public static final JsonCodec JSON = new com.hedera.hapi.node.token.codec.AccountInfoJsonCodec();
    
    /** Default instance with all fields set to default values */
    public static final AccountInfo DEFAULT = newBuilder().build();
    /**
     * Create a pre-populated AccountInfo.
     * 
     * @param accountID (1) The account ID for which this information applies, 
     * @param contractAccountID (2) The Contract Account ID comprising of both the contract instance and the cryptocurrency
     *                          account owned by the contract instance, in the format used by Solidity, 
     * @param deleted (3) If true, then this account has been deleted, it will disappear when it expires, and all
     *                transactions for it will fail except the transaction to extend its expiration date, 
     * @param proxyAccountID (4) [Deprecated] The Account ID of the account to which this is proxy staked. If proxyAccountID is null,
     *                       or is an invalid account, or is an account that isn't a node, then this account is
     *                       automatically proxy staked to a node chosen by the network, but without earning payments.
     *                       If the proxyAccountID account refuses to accept proxy staking , or if it is not currently
     *                       running a node, then it will behave as if proxyAccountID was null., 
     * @param proxyReceived (6) The total number of tinybars proxy staked to this account, 
     * @param key (7) The key for the account, which must sign in order to transfer out, or to modify the
     *            account in any way other than extending its expiration date., 
     * @param balance (8) The current balance of account in tinybars, 
     * @param generateSendRecordThreshold (9) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
     *                                    transaction that decreases the balance of this account by more than the threshold, 
     * @param generateReceiveRecordThreshold (10) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
     *                                       transaction that increases the balance of this account by more than the threshold, 
     * @param receiverSigRequired (11) If true, no transaction can transfer to this account unless signed by this account's key, 
     * @param expirationTime (12) The TimeStamp time at which this account is set to expire, 
     * @param autoRenewPeriod (13) The duration for expiration time will extend every this many seconds. If there are
     *                        insufficient funds, then it extends as long as possible. If it is empty when it expires,
     *                        then it is deleted., 
     * @param liveHashes (14) All of the livehashes attached to the account (each of which is a hash along with the
     *                   keys that authorized it and can delete it), 
     * @param tokenRelationships (15) [DEPRECATED] The metadata of the tokens associated to the account. This field was 
     *                           deprecated by HIP-367, which allowed 
     *                           an account to be associated to an unlimited number of tokens. This scale makes it more 
     *                           efficient for users to consult mirror nodes to review their token associations., 
     * @param memo (16) The memo associated with the account, 
     * @param ownedNfts (17) The number of NFTs owned by this account, 
     * @param maxAutomaticTokenAssociations (18) The maximum number of tokens that an Account can be implicitly associated with., 
     * @param alias (19) The alias of this account, 
     * @param ledgerId (20) The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs., 
     * @param ethereumNonce (21) The ethereum transaction nonce associated with this account., 
     * @param stakingInfo (22) Staking metadata for this account.
     */
    public AccountInfo(AccountID accountID, String contractAccountID, boolean deleted, AccountID proxyAccountID, long proxyReceived, Key key, long balance, long generateSendRecordThreshold, long generateReceiveRecordThreshold, boolean receiverSigRequired, Timestamp expirationTime, Duration autoRenewPeriod, List liveHashes, List tokenRelationships, String memo, long ownedNfts, int maxAutomaticTokenAssociations, Bytes alias, Bytes ledgerId, long ethereumNonce, StakingInfo stakingInfo) {
        this.accountID = accountID;
        this.contractAccountID = contractAccountID != null ? contractAccountID : "";
        this.deleted = deleted;
        this.proxyAccountID = proxyAccountID;
        this.proxyReceived = proxyReceived;
        this.key = key;
        this.balance = balance;
        this.generateSendRecordThreshold = generateSendRecordThreshold;
        this.generateReceiveRecordThreshold = generateReceiveRecordThreshold;
        this.receiverSigRequired = receiverSigRequired;
        this.expirationTime = expirationTime;
        this.autoRenewPeriod = autoRenewPeriod;
        this.liveHashes = liveHashes == null ? Collections.emptyList() : liveHashes;
        this.tokenRelationships = tokenRelationships == null ? Collections.emptyList() : tokenRelationships;
        this.memo = memo != null ? memo : "";
        this.ownedNfts = ownedNfts;
        this.maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;
        this.alias = alias != null ? alias : Bytes.EMPTY;
        this.ledgerId = ledgerId != null ? ledgerId : Bytes.EMPTY;
        this.ethereumNonce = ethereumNonce;
        this.stakingInfo = stakingInfo;
    }
    /**
    * Override the default hashCode method for
    * all other objects to make hashCode
    */
    @Override
    public int hashCode() {
    	int result = 1;
        if (accountID != null && !accountID.equals(DEFAULT.accountID)) {
           result = 31 * result + accountID.hashCode();
        }
        if (contractAccountID != null && !contractAccountID.equals(DEFAULT.contractAccountID)) {
           result = 31 * result + contractAccountID.hashCode();
        }
        if (deleted != DEFAULT.deleted) {
           result = 31 * result + Boolean.hashCode(deleted);
        }
        if (proxyAccountID != null && !proxyAccountID.equals(DEFAULT.proxyAccountID)) {
           result = 31 * result + proxyAccountID.hashCode();
        }
        if (proxyReceived != DEFAULT.proxyReceived) {
            result = 31 * result + Long.hashCode(proxyReceived);
        }
        if (key != null && !key.equals(DEFAULT.key)) {
           result = 31 * result + key.hashCode();
        }
        if (balance != DEFAULT.balance) {
            result = 31 * result + Long.hashCode(balance);
        }
        if (generateSendRecordThreshold != DEFAULT.generateSendRecordThreshold) {
            result = 31 * result + Long.hashCode(generateSendRecordThreshold);
        }
        if (generateReceiveRecordThreshold != DEFAULT.generateReceiveRecordThreshold) {
            result = 31 * result + Long.hashCode(generateReceiveRecordThreshold);
        }
        if (receiverSigRequired != DEFAULT.receiverSigRequired) {
           result = 31 * result + Boolean.hashCode(receiverSigRequired);
        }
        if (expirationTime != null && !expirationTime.equals(DEFAULT.expirationTime)) {
           result = 31 * result + expirationTime.hashCode();
        }
        if (autoRenewPeriod != null && !autoRenewPeriod.equals(DEFAULT.autoRenewPeriod)) {
           result = 31 * result + autoRenewPeriod.hashCode();
        }
        java.util.List list$liveHashes = liveHashes;
        if (list$liveHashes != null) {
            for (Object o : list$liveHashes) {
                if (o != null) {
                    result = 31 * result + o.hashCode();
                } else {
                    result = 31 * result;
                }
           }
        }
        java.util.List list$tokenRelationships = tokenRelationships;
        if (list$tokenRelationships != null) {
            for (Object o : list$tokenRelationships) {
                if (o != null) {
                    result = 31 * result + o.hashCode();
                } else {
                    result = 31 * result;
                }
           }
        }
        if (memo != null && !memo.equals(DEFAULT.memo)) {
           result = 31 * result + memo.hashCode();
        }
        if (ownedNfts != DEFAULT.ownedNfts) {
            result = 31 * result + Long.hashCode(ownedNfts);
        }
        if (maxAutomaticTokenAssociations != DEFAULT.maxAutomaticTokenAssociations) {
            result = 31 * result + Integer.hashCode(maxAutomaticTokenAssociations);
        }
        if (alias != null && !alias.equals(DEFAULT.alias)) {
           result = 31 * result + alias.hashCode();
        }
        if (ledgerId != null && !ledgerId.equals(DEFAULT.ledgerId)) {
           result = 31 * result + ledgerId.hashCode();
        }
        if (ethereumNonce != DEFAULT.ethereumNonce) {
            result = 31 * result + Long.hashCode(ethereumNonce);
        }
        if (stakingInfo != null && !stakingInfo.equals(DEFAULT.stakingInfo)) {
           result = 31 * result + stakingInfo.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;
        }
        AccountInfo thatObj = (AccountInfo)that;
        if (accountID == null && thatObj.accountID != null) {
            return false;
        }
        if (accountID != null && !accountID.equals(thatObj.accountID)) {
            return false;
        }
        if (contractAccountID == null && thatObj.contractAccountID != null) {
            return false;
        }
        if (contractAccountID != null && !contractAccountID.equals(thatObj.contractAccountID)) {
            return false;
        }
        if (deleted != thatObj.deleted) {
            return false;
        }
        if (proxyAccountID == null && thatObj.proxyAccountID != null) {
            return false;
        }
        if (proxyAccountID != null && !proxyAccountID.equals(thatObj.proxyAccountID)) {
            return false;
        }
        if (proxyReceived != thatObj.proxyReceived) {
            return false;
        }
        if (key == null && thatObj.key != null) {
            return false;
        }
        if (key != null && !key.equals(thatObj.key)) {
            return false;
        }
        if (balance != thatObj.balance) {
            return false;
        }
        if (generateSendRecordThreshold != thatObj.generateSendRecordThreshold) {
            return false;
        }
        if (generateReceiveRecordThreshold != thatObj.generateReceiveRecordThreshold) {
            return false;
        }
        if (receiverSigRequired != thatObj.receiverSigRequired) {
            return false;
        }
        if (expirationTime == null && thatObj.expirationTime != null) {
            return false;
        }
        if (expirationTime != null && !expirationTime.equals(thatObj.expirationTime)) {
            return false;
        }
        if (autoRenewPeriod == null && thatObj.autoRenewPeriod != null) {
            return false;
        }
        if (autoRenewPeriod != null && !autoRenewPeriod.equals(thatObj.autoRenewPeriod)) {
            return false;
        }
        if (this.liveHashes == null && thatObj.liveHashes != null) {
            return false;
        }
        
        if (this.liveHashes != null && !liveHashes.equals(thatObj.liveHashes)) {
            return false;
        }
        if (this.tokenRelationships == null && thatObj.tokenRelationships != null) {
            return false;
        }
        
        if (this.tokenRelationships != null && !tokenRelationships.equals(thatObj.tokenRelationships)) {
            return false;
        }
        if (memo == null && thatObj.memo != null) {
            return false;
        }
        if (memo != null && !memo.equals(thatObj.memo)) {
            return false;
        }
        if (ownedNfts != thatObj.ownedNfts) {
            return false;
        }
        if (maxAutomaticTokenAssociations != thatObj.maxAutomaticTokenAssociations) {
            return false;
        }
        if (alias == null && thatObj.alias != null) {
            return false;
        }
        if (alias != null && !alias.equals(thatObj.alias)) {
            return false;
        }
        if (ledgerId == null && thatObj.ledgerId != null) {
            return false;
        }
        if (ledgerId != null && !ledgerId.equals(thatObj.ledgerId)) {
            return false;
        }
        if (ethereumNonce != thatObj.ethereumNonce) {
            return false;
        }
        if (stakingInfo == null && thatObj.stakingInfo != null) {
            return false;
        }
        if (stakingInfo != null && !stakingInfo.equals(thatObj.stakingInfo)) {
            return false;
        }
        return true;
    }
    /**
     * Convenience method to check if the accountID has a value
     *
     * @return true of the accountID has a value
     */
    public boolean hasAccountID() {
    	return accountID != null;
    }
    
    /**
     * Gets the value for accountID if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if accountID is null
     * @return the value for accountID if it has a value, or else returns the default value
     */
    public AccountID accountIDOrElse(@NonNull final AccountID defaultValue) {
    	return hasAccountID() ? accountID : defaultValue;
    }
    
    /**
     * Gets the value for accountID if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for accountID if it has a value
     * @throws NullPointerException if accountID is null
     */
    public @NonNull AccountID accountIDOrThrow() {
    	return requireNonNull(accountID, "Field accountID is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the accountID has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifAccountID(@NonNull final Consumer ifPresent) {
    	if (hasAccountID()) {
    		ifPresent.accept(accountID);
    	}
    }

    /**
     * Convenience method to check if the proxyAccountID has a value
     *
     * @return true of the proxyAccountID has a value
     */
    public boolean hasProxyAccountID() {
    	return proxyAccountID != null;
    }
    
    /**
     * Gets the value for proxyAccountID if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if proxyAccountID is null
     * @return the value for proxyAccountID if it has a value, or else returns the default value
     */
    public AccountID proxyAccountIDOrElse(@NonNull final AccountID defaultValue) {
    	return hasProxyAccountID() ? proxyAccountID : defaultValue;
    }
    
    /**
     * Gets the value for proxyAccountID if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for proxyAccountID if it has a value
     * @throws NullPointerException if proxyAccountID is null
     */
    public @NonNull AccountID proxyAccountIDOrThrow() {
    	return requireNonNull(proxyAccountID, "Field proxyAccountID is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the proxyAccountID has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifProxyAccountID(@NonNull final Consumer ifPresent) {
    	if (hasProxyAccountID()) {
    		ifPresent.accept(proxyAccountID);
    	}
    }

    /**
     * Convenience method to check if the key has a value
     *
     * @return true of the key has a value
     */
    public boolean hasKey() {
    	return key != null;
    }
    
    /**
     * Gets the value for key if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if key is null
     * @return the value for key if it has a value, or else returns the default value
     */
    public Key keyOrElse(@NonNull final Key defaultValue) {
    	return hasKey() ? key : defaultValue;
    }
    
    /**
     * Gets the value for key if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for key if it has a value
     * @throws NullPointerException if key is null
     */
    public @NonNull Key keyOrThrow() {
    	return requireNonNull(key, "Field key is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the key has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifKey(@NonNull final Consumer ifPresent) {
    	if (hasKey()) {
    		ifPresent.accept(key);
    	}
    }

    /**
     * Convenience method to check if the expirationTime has a value
     *
     * @return true of the expirationTime has a value
     */
    public boolean hasExpirationTime() {
    	return expirationTime != null;
    }
    
    /**
     * Gets the value for expirationTime if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if expirationTime is null
     * @return the value for expirationTime if it has a value, or else returns the default value
     */
    public Timestamp expirationTimeOrElse(@NonNull final Timestamp defaultValue) {
    	return hasExpirationTime() ? expirationTime : defaultValue;
    }
    
    /**
     * Gets the value for expirationTime if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for expirationTime if it has a value
     * @throws NullPointerException if expirationTime is null
     */
    public @NonNull Timestamp expirationTimeOrThrow() {
    	return requireNonNull(expirationTime, "Field expirationTime is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the expirationTime has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifExpirationTime(@NonNull final Consumer ifPresent) {
    	if (hasExpirationTime()) {
    		ifPresent.accept(expirationTime);
    	}
    }

    /**
     * Convenience method to check if the autoRenewPeriod has a value
     *
     * @return true of the autoRenewPeriod has a value
     */
    public boolean hasAutoRenewPeriod() {
    	return autoRenewPeriod != null;
    }
    
    /**
     * Gets the value for autoRenewPeriod if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if autoRenewPeriod is null
     * @return the value for autoRenewPeriod if it has a value, or else returns the default value
     */
    public Duration autoRenewPeriodOrElse(@NonNull final Duration defaultValue) {
    	return hasAutoRenewPeriod() ? autoRenewPeriod : defaultValue;
    }
    
    /**
     * Gets the value for autoRenewPeriod if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for autoRenewPeriod if it has a value
     * @throws NullPointerException if autoRenewPeriod is null
     */
    public @NonNull Duration autoRenewPeriodOrThrow() {
    	return requireNonNull(autoRenewPeriod, "Field autoRenewPeriod is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the autoRenewPeriod has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifAutoRenewPeriod(@NonNull final Consumer ifPresent) {
    	if (hasAutoRenewPeriod()) {
    		ifPresent.accept(autoRenewPeriod);
    	}
    }

    /**
     * Convenience method to check if the stakingInfo has a value
     *
     * @return true of the stakingInfo has a value
     */
    public boolean hasStakingInfo() {
    	return stakingInfo != null;
    }
    
    /**
     * Gets the value for stakingInfo if it has a value, or else returns the default
     * value for the type.
     *
     * @param defaultValue the default value to return if stakingInfo is null
     * @return the value for stakingInfo if it has a value, or else returns the default value
     */
    public StakingInfo stakingInfoOrElse(@NonNull final StakingInfo defaultValue) {
    	return hasStakingInfo() ? stakingInfo : defaultValue;
    }
    
    /**
     * Gets the value for stakingInfo if it has a value, or else throws an NPE.
     * value for the type.
     *
     * @return the value for stakingInfo if it has a value
     * @throws NullPointerException if stakingInfo is null
     */
    public @NonNull StakingInfo stakingInfoOrThrow() {
    	return requireNonNull(stakingInfo, "Field stakingInfo is null");
    }
    
    /**
     * Executes the supplied {@link Consumer} if, and only if, the stakingInfo has a value
     *
     * @param ifPresent the {@link Consumer} to execute
     */
    public void ifStakingInfo(@NonNull final Consumer ifPresent) {
    	if (hasStakingInfo()) {
    		ifPresent.accept(stakingInfo);
    	}
    }


    /**
     * 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(accountID, contractAccountID, deleted, proxyAccountID, proxyReceived, key, balance, generateSendRecordThreshold, generateReceiveRecordThreshold, receiverSigRequired, expirationTime, autoRenewPeriod, liveHashes, tokenRelationships, memo, ownedNfts, maxAutomaticTokenAssociations, alias, ledgerId, ethereumNonce, stakingInfo);
    }
    
    /**
     * 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 AccountID accountID = null;
        @NonNull private String contractAccountID = "";
        private boolean deleted = false;
        @Nullable private AccountID proxyAccountID = null;
        private long proxyReceived = 0;
        @Nullable private Key key = null;
        private long balance = 0;
        private long generateSendRecordThreshold = 0;
        private long generateReceiveRecordThreshold = 0;
        private boolean receiverSigRequired = false;
        @Nullable private Timestamp expirationTime = null;
        @Nullable private Duration autoRenewPeriod = null;
        @NonNull private List liveHashes = Collections.emptyList();
        @NonNull private List tokenRelationships = Collections.emptyList();
        @NonNull private String memo = "";
        private long ownedNfts = 0;
        private int maxAutomaticTokenAssociations = 0;
        @NonNull private Bytes alias = Bytes.EMPTY;
        @NonNull private Bytes ledgerId = Bytes.EMPTY;
        private long ethereumNonce = 0;
        @Nullable private StakingInfo stakingInfo = null;
    
        /**
         * Create an empty builder
         */
        public Builder() {}
    
            /**
         * Create a pre-populated Builder.
         * 
         * @param accountID (1) The account ID for which this information applies, 
         * @param contractAccountID (2) The Contract Account ID comprising of both the contract instance and the cryptocurrency
         *                          account owned by the contract instance, in the format used by Solidity, 
         * @param deleted (3) If true, then this account has been deleted, it will disappear when it expires, and all
         *                transactions for it will fail except the transaction to extend its expiration date, 
         * @param proxyAccountID (4) [Deprecated] The Account ID of the account to which this is proxy staked. If proxyAccountID is null,
         *                       or is an invalid account, or is an account that isn't a node, then this account is
         *                       automatically proxy staked to a node chosen by the network, but without earning payments.
         *                       If the proxyAccountID account refuses to accept proxy staking , or if it is not currently
         *                       running a node, then it will behave as if proxyAccountID was null., 
         * @param proxyReceived (6) The total number of tinybars proxy staked to this account, 
         * @param key (7) The key for the account, which must sign in order to transfer out, or to modify the
         *            account in any way other than extending its expiration date., 
         * @param balance (8) The current balance of account in tinybars, 
         * @param generateSendRecordThreshold (9) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
         *                                    transaction that decreases the balance of this account by more than the threshold, 
         * @param generateReceiveRecordThreshold (10) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
         *                                       transaction that increases the balance of this account by more than the threshold, 
         * @param receiverSigRequired (11) If true, no transaction can transfer to this account unless signed by this account's key, 
         * @param expirationTime (12) The TimeStamp time at which this account is set to expire, 
         * @param autoRenewPeriod (13) The duration for expiration time will extend every this many seconds. If there are
         *                        insufficient funds, then it extends as long as possible. If it is empty when it expires,
         *                        then it is deleted., 
         * @param liveHashes (14) All of the livehashes attached to the account (each of which is a hash along with the
         *                   keys that authorized it and can delete it), 
         * @param tokenRelationships (15) [DEPRECATED] The metadata of the tokens associated to the account. This field was 
         *                           deprecated by HIP-367, which allowed 
         *                           an account to be associated to an unlimited number of tokens. This scale makes it more 
         *                           efficient for users to consult mirror nodes to review their token associations., 
         * @param memo (16) The memo associated with the account, 
         * @param ownedNfts (17) The number of NFTs owned by this account, 
         * @param maxAutomaticTokenAssociations (18) The maximum number of tokens that an Account can be implicitly associated with., 
         * @param alias (19) The alias of this account, 
         * @param ledgerId (20) The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs., 
         * @param ethereumNonce (21) The ethereum transaction nonce associated with this account., 
         * @param stakingInfo (22) Staking metadata for this account.
         */
        public Builder(AccountID accountID, String contractAccountID, boolean deleted, AccountID proxyAccountID, long proxyReceived, Key key, long balance, long generateSendRecordThreshold, long generateReceiveRecordThreshold, boolean receiverSigRequired, Timestamp expirationTime, Duration autoRenewPeriod, List liveHashes, List tokenRelationships, String memo, long ownedNfts, int maxAutomaticTokenAssociations, Bytes alias, Bytes ledgerId, long ethereumNonce, StakingInfo stakingInfo) {
            this.accountID = accountID;
            this.contractAccountID = contractAccountID != null ? contractAccountID : "";
            this.deleted = deleted;
            this.proxyAccountID = proxyAccountID;
            this.proxyReceived = proxyReceived;
            this.key = key;
            this.balance = balance;
            this.generateSendRecordThreshold = generateSendRecordThreshold;
            this.generateReceiveRecordThreshold = generateReceiveRecordThreshold;
            this.receiverSigRequired = receiverSigRequired;
            this.expirationTime = expirationTime;
            this.autoRenewPeriod = autoRenewPeriod;
            this.liveHashes = liveHashes == null ? Collections.emptyList() : liveHashes;
            this.tokenRelationships = tokenRelationships == null ? Collections.emptyList() : tokenRelationships;
            this.memo = memo != null ? memo : "";
            this.ownedNfts = ownedNfts;
            this.maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;
            this.alias = alias != null ? alias : Bytes.EMPTY;
            this.ledgerId = ledgerId != null ? ledgerId : Bytes.EMPTY;
            this.ethereumNonce = ethereumNonce;
            this.stakingInfo = stakingInfo;
        }
    
    
        /**
         * Build a new model record with data set on builder
         *
         * @return new model record with data set
         */
        public AccountInfo build() {
            return new AccountInfo(accountID, contractAccountID, deleted, proxyAccountID, proxyReceived, key, balance, generateSendRecordThreshold, generateReceiveRecordThreshold, receiverSigRequired, expirationTime, autoRenewPeriod, liveHashes, tokenRelationships, memo, ownedNfts, maxAutomaticTokenAssociations, alias, ledgerId, ethereumNonce, stakingInfo);
        }
    
            /**
         * (1) The account ID for which this information applies
         *
         * @param accountID value to set
         * @return builder to continue building with
         */
        public Builder accountID(@Nullable AccountID accountID) {
            this.accountID = accountID;
            return this;
        }
    
        /**
         * (1) The account ID for which this information applies
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder accountID(AccountID.Builder builder) {
            this.accountID = builder.build() ;
            return this;
        }
    
        /**
         * (2) The Contract Account ID comprising of both the contract instance and the cryptocurrency
         * account owned by the contract instance, in the format used by Solidity
         *
         * @param contractAccountID value to set
         * @return builder to continue building with
         */
        public Builder contractAccountID(@NonNull String contractAccountID) {
            this.contractAccountID = contractAccountID != null ? contractAccountID : "";
            return this;
        }
    
        /**
         * (3) If true, then this account has been deleted, it will disappear when it expires, and all
         * transactions for it will fail except the transaction to extend its expiration date
         *
         * @param deleted value to set
         * @return builder to continue building with
         */
        public Builder deleted(boolean deleted) {
            this.deleted = deleted;
            return this;
        }
    
        /**
         * (4) [Deprecated] The Account ID of the account to which this is proxy staked. If proxyAccountID is null,
         * or is an invalid account, or is an account that isn't a node, then this account is
         * automatically proxy staked to a node chosen by the network, but without earning payments.
         * If the proxyAccountID account refuses to accept proxy staking , or if it is not currently
         * running a node, then it will behave as if proxyAccountID was null.
         *
         * @param proxyAccountID value to set
         * @return builder to continue building with
         */
        public Builder proxyAccountID(@Nullable AccountID proxyAccountID) {
            this.proxyAccountID = proxyAccountID;
            return this;
        }
    
        /**
         * (4) [Deprecated] The Account ID of the account to which this is proxy staked. If proxyAccountID is null,
         * or is an invalid account, or is an account that isn't a node, then this account is
         * automatically proxy staked to a node chosen by the network, but without earning payments.
         * If the proxyAccountID account refuses to accept proxy staking , or if it is not currently
         * running a node, then it will behave as if proxyAccountID was null.
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder proxyAccountID(AccountID.Builder builder) {
            this.proxyAccountID = builder.build() ;
            return this;
        }
    
        /**
         * (6) The total number of tinybars proxy staked to this account
         *
         * @param proxyReceived value to set
         * @return builder to continue building with
         */
        public Builder proxyReceived(long proxyReceived) {
            this.proxyReceived = proxyReceived;
            return this;
        }
    
        /**
         * (7) The key for the account, which must sign in order to transfer out, or to modify the
         * account in any way other than extending its expiration date.
         *
         * @param key value to set
         * @return builder to continue building with
         */
        public Builder key(@Nullable Key key) {
            this.key = key;
            return this;
        }
    
        /**
         * (7) The key for the account, which must sign in order to transfer out, or to modify the
         * account in any way other than extending its expiration date.
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder key(Key.Builder builder) {
            this.key = builder.build() ;
            return this;
        }
    
        /**
         * (8) The current balance of account in tinybars
         *
         * @param balance value to set
         * @return builder to continue building with
         */
        public Builder balance(long balance) {
            this.balance = balance;
            return this;
        }
    
        /**
         * (9) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
         * transaction that decreases the balance of this account by more than the threshold
         *
         * @param generateSendRecordThreshold value to set
         * @return builder to continue building with
         */
        public Builder generateSendRecordThreshold(long generateSendRecordThreshold) {
            this.generateSendRecordThreshold = generateSendRecordThreshold;
            return this;
        }
    
        /**
         * (10) [Deprecated]. The threshold amount, in tinybars, at which a record is created of any
         * transaction that increases the balance of this account by more than the threshold
         *
         * @param generateReceiveRecordThreshold value to set
         * @return builder to continue building with
         */
        public Builder generateReceiveRecordThreshold(long generateReceiveRecordThreshold) {
            this.generateReceiveRecordThreshold = generateReceiveRecordThreshold;
            return this;
        }
    
        /**
         * (11) If true, no transaction can transfer to this account unless signed by this account's key
         *
         * @param receiverSigRequired value to set
         * @return builder to continue building with
         */
        public Builder receiverSigRequired(boolean receiverSigRequired) {
            this.receiverSigRequired = receiverSigRequired;
            return this;
        }
    
        /**
         * (12) The TimeStamp time at which this account is set to expire
         *
         * @param expirationTime value to set
         * @return builder to continue building with
         */
        public Builder expirationTime(@Nullable Timestamp expirationTime) {
            this.expirationTime = expirationTime;
            return this;
        }
    
        /**
         * (12) The TimeStamp time at which this account is set to expire
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder expirationTime(Timestamp.Builder builder) {
            this.expirationTime = builder.build() ;
            return this;
        }
    
        /**
         * (13) The duration for expiration time will extend every this many seconds. If there are
         * insufficient funds, then it extends as long as possible. If it is empty when it expires,
         * then it is deleted.
         *
         * @param autoRenewPeriod value to set
         * @return builder to continue building with
         */
        public Builder autoRenewPeriod(@Nullable Duration autoRenewPeriod) {
            this.autoRenewPeriod = autoRenewPeriod;
            return this;
        }
    
        /**
         * (13) The duration for expiration time will extend every this many seconds. If there are
         * insufficient funds, then it extends as long as possible. If it is empty when it expires,
         * then it is deleted.
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder autoRenewPeriod(Duration.Builder builder) {
            this.autoRenewPeriod = builder.build() ;
            return this;
        }
    
        /**
         * (14) All of the livehashes attached to the account (each of which is a hash along with the
         * keys that authorized it and can delete it)
         *
         * @param liveHashes value to set
         * @return builder to continue building with
         */
        public Builder liveHashes(@NonNull List liveHashes) {
            this.liveHashes = liveHashes != null ? liveHashes : Collections.emptyList();
            return this;
        }
    
        /**
         * (14) All of the livehashes attached to the account (each of which is a hash along with the
         * keys that authorized it and can delete it)
         *
         * @param values varargs value to be built into a list
         * @return builder to continue building with
         */
        public Builder liveHashes(LiveHash ... values) {
            this.liveHashes = values == null ? Collections.emptyList() :  List.of(values) ;
            return this;
        }
    
        /**
         * (15) [DEPRECATED] The metadata of the tokens associated to the account. This field was 
         * deprecated by HIP-367, which allowed 
         * an account to be associated to an unlimited number of tokens. This scale makes it more 
         * efficient for users to consult mirror nodes to review their token associations.
         *
         * @param tokenRelationships value to set
         * @return builder to continue building with
         */
        public Builder tokenRelationships(@NonNull List tokenRelationships) {
            this.tokenRelationships = tokenRelationships != null ? tokenRelationships : Collections.emptyList();
            return this;
        }
    
        /**
         * (15) [DEPRECATED] The metadata of the tokens associated to the account. This field was 
         * deprecated by HIP-367, which allowed 
         * an account to be associated to an unlimited number of tokens. This scale makes it more 
         * efficient for users to consult mirror nodes to review their token associations.
         *
         * @param values varargs value to be built into a list
         * @return builder to continue building with
         */
        public Builder tokenRelationships(TokenRelationship ... values) {
            this.tokenRelationships = values == null ? Collections.emptyList() :  List.of(values) ;
            return this;
        }
    
        /**
         * (16) The memo associated with the account
         *
         * @param memo value to set
         * @return builder to continue building with
         */
        public Builder memo(@NonNull String memo) {
            this.memo = memo != null ? memo : "";
            return this;
        }
    
        /**
         * (17) The number of NFTs owned by this account
         *
         * @param ownedNfts value to set
         * @return builder to continue building with
         */
        public Builder ownedNfts(long ownedNfts) {
            this.ownedNfts = ownedNfts;
            return this;
        }
    
        /**
         * (18) The maximum number of tokens that an Account can be implicitly associated with.
         *
         * @param maxAutomaticTokenAssociations value to set
         * @return builder to continue building with
         */
        public Builder maxAutomaticTokenAssociations(int maxAutomaticTokenAssociations) {
            this.maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;
            return this;
        }
    
        /**
         * (19) The alias of this account
         *
         * @param alias value to set
         * @return builder to continue building with
         */
        public Builder alias(@NonNull Bytes alias) {
            this.alias = alias != null ? alias : Bytes.EMPTY;
            return this;
        }
    
        /**
         * (20) The ledger ID the response was returned from; please see HIP-198 for the network-specific IDs.
         *
         * @param ledgerId value to set
         * @return builder to continue building with
         */
        public Builder ledgerId(@NonNull Bytes ledgerId) {
            this.ledgerId = ledgerId != null ? ledgerId : Bytes.EMPTY;
            return this;
        }
    
        /**
         * (21) The ethereum transaction nonce associated with this account.
         *
         * @param ethereumNonce value to set
         * @return builder to continue building with
         */
        public Builder ethereumNonce(long ethereumNonce) {
            this.ethereumNonce = ethereumNonce;
            return this;
        }
    
        /**
         * (22) Staking metadata for this account.
         *
         * @param stakingInfo value to set
         * @return builder to continue building with
         */
        public Builder stakingInfo(@Nullable StakingInfo stakingInfo) {
            this.stakingInfo = stakingInfo;
            return this;
        }
    
        /**
         * (22) Staking metadata for this account.
         *
         * @param builder A pre-populated builder
         * @return builder to continue building with
         */
        public Builder stakingInfo(StakingInfo.Builder builder) {
            this.stakingInfo = builder.build() ;
            return this;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy