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

com.hedera.hapi.block.stream.output.EthereumOutput Maven / Gradle / Ivy

The newest version!
package com.hedera.hapi.block.stream.output;

import com.hedera.hapi.streams.*;
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;

/**
 * Block Stream data for a `callEthereum` transaction.
 * 

* This message SHALL NOT duplicate information already contained in * the original transaction. * * @param sidecars (1) A list of additional outputs. *

* This field MAY record one or more additional outputs and smart * contract state changes produced during the ethereum call * transaction handling.
* This field SHALL NOT be set if the transaction handling did not * produce additional outputs.
* This field is not settled and MAY be removed or modified. * @param ethereumHash (2) An ethereum hash value. *

* This SHALL be a keccak256 hash of the ethereumData. */ public record EthereumOutput( @NonNull List sidecars, @NonNull Bytes ethereumHash ) { /** Protobuf codec for reading and writing in protobuf format */ public static final Codec PROTOBUF = new com.hedera.hapi.block.stream.output.codec.EthereumOutputProtoCodec(); /** JSON codec for reading and writing in JSON format */ public static final JsonCodec JSON = new com.hedera.hapi.block.stream.output.codec.EthereumOutputJsonCodec(); /** Default instance with all fields set to default values */ public static final EthereumOutput DEFAULT = newBuilder().build(); /** * Create a pre-populated EthereumOutput. * * @param sidecars (1) A list of additional outputs. *

* This field MAY record one or more additional outputs and smart * contract state changes produced during the ethereum call * transaction handling.
* This field SHALL NOT be set if the transaction handling did not * produce additional outputs.
* This field is not settled and MAY be removed or modified., * @param ethereumHash (2) An ethereum hash value. *

* This SHALL be a keccak256 hash of the ethereumData. */ public EthereumOutput(List sidecars, Bytes ethereumHash) { this.sidecars = sidecars == null ? Collections.emptyList() : sidecars; this.ethereumHash = ethereumHash != null ? ethereumHash : Bytes.EMPTY; } /** * Override the default hashCode method for * all other objects to make hashCode */ @Override public int hashCode() { int result = 1; java.util.List list$sidecars = sidecars; if (list$sidecars != null) { for (Object o : list$sidecars) { if (o != null) { result = 31 * result + o.hashCode(); } else { result = 31 * result; } } } if (ethereumHash != null && !ethereumHash.equals(DEFAULT.ethereumHash)) { result = 31 * result + ethereumHash.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; } EthereumOutput thatObj = (EthereumOutput)that; if (this.sidecars == null && thatObj.sidecars != null) { return false; } if (this.sidecars != null && !sidecars.equals(thatObj.sidecars)) { return false; } if (ethereumHash == null && thatObj.ethereumHash != null) { return false; } if (ethereumHash != null && !ethereumHash.equals(thatObj.ethereumHash)) { 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(sidecars, ethereumHash); } /** * 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 { @NonNull private List sidecars = Collections.emptyList(); @NonNull private Bytes ethereumHash = Bytes.EMPTY; /** * Create an empty builder */ public Builder() {} /** * Create a pre-populated Builder. * * @param sidecars (1) A list of additional outputs. *

* This field MAY record one or more additional outputs and smart * contract state changes produced during the ethereum call * transaction handling.
* This field SHALL NOT be set if the transaction handling did not * produce additional outputs.
* This field is not settled and MAY be removed or modified., * @param ethereumHash (2) An ethereum hash value. *

* This SHALL be a keccak256 hash of the ethereumData. */ public Builder(List sidecars, Bytes ethereumHash) { this.sidecars = sidecars == null ? Collections.emptyList() : sidecars; this.ethereumHash = ethereumHash != null ? ethereumHash : Bytes.EMPTY; } /** * Build a new model record with data set on builder * * @return new model record with data set */ public EthereumOutput build() { return new EthereumOutput(sidecars, ethereumHash); } /** * (1) A list of additional outputs. *

* This field MAY record one or more additional outputs and smart * contract state changes produced during the ethereum call * transaction handling.
* This field SHALL NOT be set if the transaction handling did not * produce additional outputs.
* This field is not settled and MAY be removed or modified. * * @param sidecars value to set * @return builder to continue building with */ public Builder sidecars(@NonNull List sidecars) { this.sidecars = sidecars != null ? sidecars : Collections.emptyList(); return this; } /** * (1) A list of additional outputs. *

* This field MAY record one or more additional outputs and smart * contract state changes produced during the ethereum call * transaction handling.
* This field SHALL NOT be set if the transaction handling did not * produce additional outputs.
* This field is not settled and MAY be removed or modified. * * @param values varargs value to be built into a list * @return builder to continue building with */ public Builder sidecars(TransactionSidecarRecord ... values) { this.sidecars = values == null ? Collections.emptyList() : List.of(values) ; return this; } /** * (2) An ethereum hash value. *

* This SHALL be a keccak256 hash of the ethereumData. * * @param ethereumHash value to set * @return builder to continue building with */ public Builder ethereumHash(@NonNull Bytes ethereumHash) { this.ethereumHash = ethereumHash != null ? ethereumHash : Bytes.EMPTY; return this; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy