software.amazon.awssdk.services.connect.model.RuleSummary Maven / Gradle / Ivy
Show all versions of connect Show documentation
/*
* 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.connect.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A list of ActionTypes
associated with a rule.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RuleSummary implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(RuleSummary::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField RULE_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("RuleId")
.getter(getter(RuleSummary::ruleId)).setter(setter(Builder::ruleId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleId").build()).build();
private static final SdkField RULE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RuleArn").getter(getter(RuleSummary::ruleArn)).setter(setter(Builder::ruleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleArn").build()).build();
private static final SdkField EVENT_SOURCE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EventSourceName").getter(getter(RuleSummary::eventSourceNameAsString))
.setter(setter(Builder::eventSourceName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventSourceName").build()).build();
private static final SdkField PUBLISH_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PublishStatus").getter(getter(RuleSummary::publishStatusAsString))
.setter(setter(Builder::publishStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublishStatus").build()).build();
private static final SdkField> ACTION_SUMMARIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ActionSummaries")
.getter(getter(RuleSummary::actionSummaries))
.setter(setter(Builder::actionSummaries))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionSummaries").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ActionSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CREATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTime").getter(getter(RuleSummary::createdTime)).setter(setter(Builder::createdTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTime").build()).build();
private static final SdkField LAST_UPDATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastUpdatedTime").getter(getter(RuleSummary::lastUpdatedTime)).setter(setter(Builder::lastUpdatedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastUpdatedTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, RULE_ID_FIELD,
RULE_ARN_FIELD, EVENT_SOURCE_NAME_FIELD, PUBLISH_STATUS_FIELD, ACTION_SUMMARIES_FIELD, CREATED_TIME_FIELD,
LAST_UPDATED_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String ruleId;
private final String ruleArn;
private final String eventSourceName;
private final String publishStatus;
private final List actionSummaries;
private final Instant createdTime;
private final Instant lastUpdatedTime;
private RuleSummary(BuilderImpl builder) {
this.name = builder.name;
this.ruleId = builder.ruleId;
this.ruleArn = builder.ruleArn;
this.eventSourceName = builder.eventSourceName;
this.publishStatus = builder.publishStatus;
this.actionSummaries = builder.actionSummaries;
this.createdTime = builder.createdTime;
this.lastUpdatedTime = builder.lastUpdatedTime;
}
/**
*
* The name of the rule.
*
*
* @return The name of the rule.
*/
public final String name() {
return name;
}
/**
*
* A unique identifier for the rule.
*
*
* @return A unique identifier for the rule.
*/
public final String ruleId() {
return ruleId;
}
/**
*
* The Amazon Resource Name (ARN) of the rule.
*
*
* @return The Amazon Resource Name (ARN) of the rule.
*/
public final String ruleArn() {
return ruleArn;
}
/**
*
* The name of the event source.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #eventSourceName}
* will return {@link EventSourceName#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #eventSourceNameAsString}.
*
*
* @return The name of the event source.
* @see EventSourceName
*/
public final EventSourceName eventSourceName() {
return EventSourceName.fromValue(eventSourceName);
}
/**
*
* The name of the event source.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #eventSourceName}
* will return {@link EventSourceName#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #eventSourceNameAsString}.
*
*
* @return The name of the event source.
* @see EventSourceName
*/
public final String eventSourceNameAsString() {
return eventSourceName;
}
/**
*
* The publish status of the rule.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #publishStatus}
* will return {@link RulePublishStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #publishStatusAsString}.
*
*
* @return The publish status of the rule.
* @see RulePublishStatus
*/
public final RulePublishStatus publishStatus() {
return RulePublishStatus.fromValue(publishStatus);
}
/**
*
* The publish status of the rule.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #publishStatus}
* will return {@link RulePublishStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #publishStatusAsString}.
*
*
* @return The publish status of the rule.
* @see RulePublishStatus
*/
public final String publishStatusAsString() {
return publishStatus;
}
/**
* For responses, this returns true if the service returned a value for the ActionSummaries property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasActionSummaries() {
return actionSummaries != null && !(actionSummaries instanceof SdkAutoConstructList);
}
/**
*
* A list of ActionTypes associated with a rule.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasActionSummaries} method.
*
*
* @return A list of ActionTypes associated with a rule.
*/
public final List actionSummaries() {
return actionSummaries;
}
/**
*
* The timestamp for when the rule was created.
*
*
* @return The timestamp for when the rule was created.
*/
public final Instant createdTime() {
return createdTime;
}
/**
*
* The timestamp for when the rule was last updated.
*
*
* @return The timestamp for when the rule was last updated.
*/
public final Instant lastUpdatedTime() {
return lastUpdatedTime;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(ruleId());
hashCode = 31 * hashCode + Objects.hashCode(ruleArn());
hashCode = 31 * hashCode + Objects.hashCode(eventSourceNameAsString());
hashCode = 31 * hashCode + Objects.hashCode(publishStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasActionSummaries() ? actionSummaries() : null);
hashCode = 31 * hashCode + Objects.hashCode(createdTime());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTime());
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 RuleSummary)) {
return false;
}
RuleSummary other = (RuleSummary) obj;
return Objects.equals(name(), other.name()) && Objects.equals(ruleId(), other.ruleId())
&& Objects.equals(ruleArn(), other.ruleArn())
&& Objects.equals(eventSourceNameAsString(), other.eventSourceNameAsString())
&& Objects.equals(publishStatusAsString(), other.publishStatusAsString())
&& hasActionSummaries() == other.hasActionSummaries()
&& Objects.equals(actionSummaries(), other.actionSummaries())
&& Objects.equals(createdTime(), other.createdTime())
&& Objects.equals(lastUpdatedTime(), other.lastUpdatedTime());
}
/**
* 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("RuleSummary").add("Name", name()).add("RuleId", ruleId()).add("RuleArn", ruleArn())
.add("EventSourceName", eventSourceNameAsString()).add("PublishStatus", publishStatusAsString())
.add("ActionSummaries", hasActionSummaries() ? actionSummaries() : null).add("CreatedTime", createdTime())
.add("LastUpdatedTime", lastUpdatedTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "RuleId":
return Optional.ofNullable(clazz.cast(ruleId()));
case "RuleArn":
return Optional.ofNullable(clazz.cast(ruleArn()));
case "EventSourceName":
return Optional.ofNullable(clazz.cast(eventSourceNameAsString()));
case "PublishStatus":
return Optional.ofNullable(clazz.cast(publishStatusAsString()));
case "ActionSummaries":
return Optional.ofNullable(clazz.cast(actionSummaries()));
case "CreatedTime":
return Optional.ofNullable(clazz.cast(createdTime()));
case "LastUpdatedTime":
return Optional.ofNullable(clazz.cast(lastUpdatedTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function