Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.fis.model.Action 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.fis.model;
import java.beans.Transient;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes an action. For more information, see FIS actions in the Fault
* Injection Simulator User Guide .
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Action implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(Action::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(Action::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField> PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("parameters")
.getter(getter(Action::parameters))
.setter(setter(Builder::parameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("parameters").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ActionParameter::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField> TARGETS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("targets")
.getter(getter(Action::targets))
.setter(setter(Builder::targets))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("targets").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ActionTarget::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("tags")
.getter(getter(Action::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, DESCRIPTION_FIELD,
PARAMETERS_FIELD, TARGETS_FIELD, TAGS_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final String description;
private final Map parameters;
private final Map targets;
private final Map tags;
private Action(BuilderImpl builder) {
this.id = builder.id;
this.description = builder.description;
this.parameters = builder.parameters;
this.targets = builder.targets;
this.tags = builder.tags;
}
/**
*
* The ID of the action.
*
*
* @return The ID of the action.
*/
public final String id() {
return id;
}
/**
*
* The description for the action.
*
*
* @return The description for the action.
*/
public final String description() {
return description;
}
/**
* For responses, this returns true if the service returned a value for the Parameters 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 hasParameters() {
return parameters != null && !(parameters instanceof SdkAutoConstructMap);
}
/**
*
* The action parameters, if applicable.
*
*
* 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 #hasParameters} method.
*
*
* @return The action parameters, if applicable.
*/
public final Map parameters() {
return parameters;
}
/**
* For responses, this returns true if the service returned a value for the Targets 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 hasTargets() {
return targets != null && !(targets instanceof SdkAutoConstructMap);
}
/**
*
* The supported targets for the action.
*
*
* 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 #hasTargets} method.
*
*
* @return The supported targets for the action.
*/
public final Map targets() {
return targets;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructMap);
}
/**
*
* The tags for the action.
*
*
* 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 #hasTags} method.
*
*
* @return The tags for the action.
*/
public final Map tags() {
return tags;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(hasParameters() ? parameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasTargets() ? targets() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
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 Action)) {
return false;
}
Action other = (Action) obj;
return Objects.equals(id(), other.id()) && Objects.equals(description(), other.description())
&& hasParameters() == other.hasParameters() && Objects.equals(parameters(), other.parameters())
&& hasTargets() == other.hasTargets() && Objects.equals(targets(), other.targets())
&& hasTags() == other.hasTags() && Objects.equals(tags(), other.tags());
}
/**
* 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("Action").add("Id", id()).add("Description", description())
.add("Parameters", hasParameters() ? parameters() : null).add("Targets", hasTargets() ? targets() : null)
.add("Tags", hasTags() ? tags() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "parameters":
return Optional.ofNullable(clazz.cast(parameters()));
case "targets":
return Optional.ofNullable(clazz.cast(targets()));
case "tags":
return Optional.ofNullable(clazz.cast(tags()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((Action) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* The ID of the action.
*
*
* @param id
* The ID of the action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder id(String id);
/**
*
* The description for the action.
*
*
* @param description
* The description for the action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder description(String description);
/**
*
* The action parameters, if applicable.
*
*
* @param parameters
* The action parameters, if applicable.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder parameters(Map parameters);
/**
*
* The supported targets for the action.
*
*
* @param targets
* The supported targets for the action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder targets(Map targets);
/**
*
* The tags for the action.
*
*
* @param tags
* The tags for the action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tags(Map tags);
}
static final class BuilderImpl implements Builder {
private String id;
private String description;
private Map parameters = DefaultSdkAutoConstructMap.getInstance();
private Map targets = DefaultSdkAutoConstructMap.getInstance();
private Map tags = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(Action model) {
id(model.id);
description(model.description);
parameters(model.parameters);
targets(model.targets);
tags(model.tags);
}
public final String getId() {
return id;
}
public final void setId(String id) {
this.id = id;
}
@Override
@Transient
public final Builder id(String id) {
this.id = id;
return this;
}
public final String getDescription() {
return description;
}
public final void setDescription(String description) {
this.description = description;
}
@Override
@Transient
public final Builder description(String description) {
this.description = description;
return this;
}
public final Map getParameters() {
Map result = ActionParameterMapCopier.copyToBuilder(this.parameters);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setParameters(Map parameters) {
this.parameters = ActionParameterMapCopier.copyFromBuilder(parameters);
}
@Override
@Transient
public final Builder parameters(Map parameters) {
this.parameters = ActionParameterMapCopier.copy(parameters);
return this;
}
public final Map getTargets() {
Map result = ActionTargetMapCopier.copyToBuilder(this.targets);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setTargets(Map targets) {
this.targets = ActionTargetMapCopier.copyFromBuilder(targets);
}
@Override
@Transient
public final Builder targets(Map targets) {
this.targets = ActionTargetMapCopier.copy(targets);
return this;
}
public final Map getTags() {
if (tags instanceof SdkAutoConstructMap) {
return null;
}
return tags;
}
public final void setTags(Map tags) {
this.tags = TagMapCopier.copy(tags);
}
@Override
@Transient
public final Builder tags(Map tags) {
this.tags = TagMapCopier.copy(tags);
return this;
}
@Override
public Action build() {
return new Action(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}