
software.amazon.awssdk.services.iotthingsgraph.model.FlowExecutionMessage 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.iotthingsgraph.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* An object that contains information about a flow event.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class FlowExecutionMessage implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("messageId").getter(getter(FlowExecutionMessage::messageId)).setter(setter(Builder::messageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("messageId").build()).build();
private static final SdkField EVENT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("eventType").getter(getter(FlowExecutionMessage::eventTypeAsString)).setter(setter(Builder::eventType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eventType").build()).build();
private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("timestamp").getter(getter(FlowExecutionMessage::timestamp)).setter(setter(Builder::timestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("timestamp").build()).build();
private static final SdkField PAYLOAD_FIELD = SdkField. builder(MarshallingType.STRING).memberName("payload")
.getter(getter(FlowExecutionMessage::payload)).setter(setter(Builder::payload))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("payload").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(MESSAGE_ID_FIELD,
EVENT_TYPE_FIELD, TIMESTAMP_FIELD, PAYLOAD_FIELD));
private static final long serialVersionUID = 1L;
private final String messageId;
private final String eventType;
private final Instant timestamp;
private final String payload;
private FlowExecutionMessage(BuilderImpl builder) {
this.messageId = builder.messageId;
this.eventType = builder.eventType;
this.timestamp = builder.timestamp;
this.payload = builder.payload;
}
/**
*
* The unique identifier of the message.
*
*
* @return The unique identifier of the message.
*/
public String messageId() {
return messageId;
}
/**
*
* The type of flow event .
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #eventType} will
* return {@link FlowExecutionEventType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #eventTypeAsString}.
*
*
* @return The type of flow event .
* @see FlowExecutionEventType
*/
public FlowExecutionEventType eventType() {
return FlowExecutionEventType.fromValue(eventType);
}
/**
*
* The type of flow event .
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #eventType} will
* return {@link FlowExecutionEventType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #eventTypeAsString}.
*
*
* @return The type of flow event .
* @see FlowExecutionEventType
*/
public String eventTypeAsString() {
return eventType;
}
/**
*
* The date and time when the message was last updated.
*
*
* @return The date and time when the message was last updated.
*/
public Instant timestamp() {
return timestamp;
}
/**
*
* A string containing information about the flow event.
*
*
* @return A string containing information about the flow event.
*/
public String payload() {
return payload;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(messageId());
hashCode = 31 * hashCode + Objects.hashCode(eventTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(timestamp());
hashCode = 31 * hashCode + Objects.hashCode(payload());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof FlowExecutionMessage)) {
return false;
}
FlowExecutionMessage other = (FlowExecutionMessage) obj;
return Objects.equals(messageId(), other.messageId()) && Objects.equals(eventTypeAsString(), other.eventTypeAsString())
&& Objects.equals(timestamp(), other.timestamp()) && Objects.equals(payload(), other.payload());
}
/**
* 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 String toString() {
return ToString.builder("FlowExecutionMessage").add("MessageId", messageId()).add("EventType", eventTypeAsString())
.add("Timestamp", timestamp()).add("Payload", payload()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "messageId":
return Optional.ofNullable(clazz.cast(messageId()));
case "eventType":
return Optional.ofNullable(clazz.cast(eventTypeAsString()));
case "timestamp":
return Optional.ofNullable(clazz.cast(timestamp()));
case "payload":
return Optional.ofNullable(clazz.cast(payload()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function