
software.amazon.awssdk.services.managedblockchainquery.model.TransactionEvent Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.managedblockchainquery.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The container for the properties of a transaction event.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TransactionEvent implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NETWORK_FIELD = SdkField. builder(MarshallingType.STRING).memberName("network")
.getter(getter(TransactionEvent::networkAsString)).setter(setter(Builder::network))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("network").build()).build();
private static final SdkField TRANSACTION_HASH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("transactionHash").getter(getter(TransactionEvent::transactionHash))
.setter(setter(Builder::transactionHash))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("transactionHash").build()).build();
private static final SdkField EVENT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("eventType").getter(getter(TransactionEvent::eventTypeAsString)).setter(setter(Builder::eventType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eventType").build()).build();
private static final SdkField FROM_FIELD = SdkField. builder(MarshallingType.STRING).memberName("from")
.getter(getter(TransactionEvent::from)).setter(setter(Builder::from))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("from").build()).build();
private static final SdkField TO_FIELD = SdkField. builder(MarshallingType.STRING).memberName("to")
.getter(getter(TransactionEvent::to)).setter(setter(Builder::to))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("to").build()).build();
private static final SdkField VALUE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("value")
.getter(getter(TransactionEvent::value)).setter(setter(Builder::value))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("value").build()).build();
private static final SdkField CONTRACT_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("contractAddress").getter(getter(TransactionEvent::contractAddress))
.setter(setter(Builder::contractAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("contractAddress").build()).build();
private static final SdkField TOKEN_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("tokenId").getter(getter(TransactionEvent::tokenId)).setter(setter(Builder::tokenId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tokenId").build()).build();
private static final SdkField TRANSACTION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("transactionId").getter(getter(TransactionEvent::transactionId)).setter(setter(Builder::transactionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("transactionId").build()).build();
private static final SdkField VOUT_INDEX_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("voutIndex").getter(getter(TransactionEvent::voutIndex)).setter(setter(Builder::voutIndex))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("voutIndex").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NETWORK_FIELD,
TRANSACTION_HASH_FIELD, EVENT_TYPE_FIELD, FROM_FIELD, TO_FIELD, VALUE_FIELD, CONTRACT_ADDRESS_FIELD, TOKEN_ID_FIELD,
TRANSACTION_ID_FIELD, VOUT_INDEX_FIELD));
private static final long serialVersionUID = 1L;
private final String network;
private final String transactionHash;
private final String eventType;
private final String from;
private final String to;
private final String value;
private final String contractAddress;
private final String tokenId;
private final String transactionId;
private final Integer voutIndex;
private TransactionEvent(BuilderImpl builder) {
this.network = builder.network;
this.transactionHash = builder.transactionHash;
this.eventType = builder.eventType;
this.from = builder.from;
this.to = builder.to;
this.value = builder.value;
this.contractAddress = builder.contractAddress;
this.tokenId = builder.tokenId;
this.transactionId = builder.transactionId;
this.voutIndex = builder.voutIndex;
}
/**
*
* The blockchain network where the transaction occurred.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #network} will
* return {@link QueryNetwork#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #networkAsString}.
*
*
* @return The blockchain network where the transaction occurred.
* @see QueryNetwork
*/
public final QueryNetwork network() {
return QueryNetwork.fromValue(network);
}
/**
*
* The blockchain network where the transaction occurred.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #network} will
* return {@link QueryNetwork#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #networkAsString}.
*
*
* @return The blockchain network where the transaction occurred.
* @see QueryNetwork
*/
public final String networkAsString() {
return network;
}
/**
*
* The hash of the transaction. It is generated whenever a transaction is verified and added to the blockchain.
*
*
* @return The hash of the transaction. It is generated whenever a transaction is verified and added to the
* blockchain.
*/
public final String transactionHash() {
return transactionHash;
}
/**
*
* The type of transaction event.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #eventType} will
* return {@link QueryTransactionEventType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #eventTypeAsString}.
*
*
* @return The type of transaction event.
* @see QueryTransactionEventType
*/
public final QueryTransactionEventType eventType() {
return QueryTransactionEventType.fromValue(eventType);
}
/**
*
* The type of transaction event.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #eventType} will
* return {@link QueryTransactionEventType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #eventTypeAsString}.
*
*
* @return The type of transaction event.
* @see QueryTransactionEventType
*/
public final String eventTypeAsString() {
return eventType;
}
/**
*
* The wallet address initiating the transaction. It can either be a public key or a contract.
*
*
* @return The wallet address initiating the transaction. It can either be a public key or a contract.
*/
public final String from() {
return from;
}
/**
*
* The wallet address receiving the transaction. It can either be a public key or a contract.
*
*
* @return The wallet address receiving the transaction. It can either be a public key or a contract.
*/
public final String to() {
return to;
}
/**
*
* The value that was transacted.
*
*
* @return The value that was transacted.
*/
public final String value() {
return value;
}
/**
*
* The blockchain address. for the contract
*
*
* @return The blockchain address. for the contract
*/
public final String contractAddress() {
return contractAddress;
}
/**
*
* The unique identifier for the token involved in the transaction.
*
*
* @return The unique identifier for the token involved in the transaction.
*/
public final String tokenId() {
return tokenId;
}
/**
*
* The unique identifier of the transaction. It is generated whenever a transaction is verified and added to the
* blockchain.
*
*
* @return The unique identifier of the transaction. It is generated whenever a transaction is verified and added to
* the blockchain.
*/
public final String transactionId() {
return transactionId;
}
/**
*
* The position of the vout in the transaction output list.
*
*
* @return The position of the vout in the transaction output list.
*/
public final Integer voutIndex() {
return voutIndex;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(networkAsString());
hashCode = 31 * hashCode + Objects.hashCode(transactionHash());
hashCode = 31 * hashCode + Objects.hashCode(eventTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(from());
hashCode = 31 * hashCode + Objects.hashCode(to());
hashCode = 31 * hashCode + Objects.hashCode(value());
hashCode = 31 * hashCode + Objects.hashCode(contractAddress());
hashCode = 31 * hashCode + Objects.hashCode(tokenId());
hashCode = 31 * hashCode + Objects.hashCode(transactionId());
hashCode = 31 * hashCode + Objects.hashCode(voutIndex());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TransactionEvent)) {
return false;
}
TransactionEvent other = (TransactionEvent) obj;
return Objects.equals(networkAsString(), other.networkAsString())
&& Objects.equals(transactionHash(), other.transactionHash())
&& Objects.equals(eventTypeAsString(), other.eventTypeAsString()) && Objects.equals(from(), other.from())
&& Objects.equals(to(), other.to()) && Objects.equals(value(), other.value())
&& Objects.equals(contractAddress(), other.contractAddress()) && Objects.equals(tokenId(), other.tokenId())
&& Objects.equals(transactionId(), other.transactionId()) && Objects.equals(voutIndex(), other.voutIndex());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("TransactionEvent").add("Network", networkAsString()).add("TransactionHash", transactionHash())
.add("EventType", eventTypeAsString()).add("From", from()).add("To", to()).add("Value", value())
.add("ContractAddress", contractAddress()).add("TokenId", tokenId()).add("TransactionId", transactionId())
.add("VoutIndex", voutIndex()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "network":
return Optional.ofNullable(clazz.cast(networkAsString()));
case "transactionHash":
return Optional.ofNullable(clazz.cast(transactionHash()));
case "eventType":
return Optional.ofNullable(clazz.cast(eventTypeAsString()));
case "from":
return Optional.ofNullable(clazz.cast(from()));
case "to":
return Optional.ofNullable(clazz.cast(to()));
case "value":
return Optional.ofNullable(clazz.cast(value()));
case "contractAddress":
return Optional.ofNullable(clazz.cast(contractAddress()));
case "tokenId":
return Optional.ofNullable(clazz.cast(tokenId()));
case "transactionId":
return Optional.ofNullable(clazz.cast(transactionId()));
case "voutIndex":
return Optional.ofNullable(clazz.cast(voutIndex()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function