software.amazon.awssdk.services.snowball.model.JobResource Maven / Gradle / Ivy
Show all versions of snowball 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.snowball.model;
import java.io.Serializable;
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;
/**
*
* Contains an array of Amazon Web Services resource objects. Each object represents an Amazon S3 bucket, an Lambda
* function, or an Amazon Machine Image (AMI) based on Amazon EC2 that is associated with a particular job.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class JobResource implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField> S3_RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("S3Resources")
.getter(getter(JobResource::s3Resources))
.setter(setter(Builder::s3Resources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3Resources").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(S3Resource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> LAMBDA_RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("LambdaResources")
.getter(getter(JobResource::lambdaResources))
.setter(setter(Builder::lambdaResources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LambdaResources").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(LambdaResource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> EC2_AMI_RESOURCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Ec2AmiResources")
.getter(getter(JobResource::ec2AmiResources))
.setter(setter(Builder::ec2AmiResources))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Ec2AmiResources").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Ec2AmiResource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(S3_RESOURCES_FIELD,
LAMBDA_RESOURCES_FIELD, EC2_AMI_RESOURCES_FIELD));
private static final long serialVersionUID = 1L;
private final List s3Resources;
private final List lambdaResources;
private final List ec2AmiResources;
private JobResource(BuilderImpl builder) {
this.s3Resources = builder.s3Resources;
this.lambdaResources = builder.lambdaResources;
this.ec2AmiResources = builder.ec2AmiResources;
}
/**
* For responses, this returns true if the service returned a value for the S3Resources 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 hasS3Resources() {
return s3Resources != null && !(s3Resources instanceof SdkAutoConstructList);
}
/**
*
* An array of S3Resource
objects.
*
*
* 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 #hasS3Resources} method.
*
*
* @return An array of S3Resource
objects.
*/
public final List s3Resources() {
return s3Resources;
}
/**
* For responses, this returns true if the service returned a value for the LambdaResources 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 hasLambdaResources() {
return lambdaResources != null && !(lambdaResources instanceof SdkAutoConstructList);
}
/**
*
* The Python-language Lambda functions for this job.
*
*
* 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 #hasLambdaResources} method.
*
*
* @return The Python-language Lambda functions for this job.
*/
public final List lambdaResources() {
return lambdaResources;
}
/**
* For responses, this returns true if the service returned a value for the Ec2AmiResources 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 hasEc2AmiResources() {
return ec2AmiResources != null && !(ec2AmiResources instanceof SdkAutoConstructList);
}
/**
*
* The Amazon Machine Images (AMIs) associated with this job.
*
*
* 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 #hasEc2AmiResources} method.
*
*
* @return The Amazon Machine Images (AMIs) associated with this job.
*/
public final List ec2AmiResources() {
return ec2AmiResources;
}
@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(hasS3Resources() ? s3Resources() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasLambdaResources() ? lambdaResources() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasEc2AmiResources() ? ec2AmiResources() : 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 JobResource)) {
return false;
}
JobResource other = (JobResource) obj;
return hasS3Resources() == other.hasS3Resources() && Objects.equals(s3Resources(), other.s3Resources())
&& hasLambdaResources() == other.hasLambdaResources()
&& Objects.equals(lambdaResources(), other.lambdaResources())
&& hasEc2AmiResources() == other.hasEc2AmiResources()
&& Objects.equals(ec2AmiResources(), other.ec2AmiResources());
}
/**
* 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("JobResource").add("S3Resources", hasS3Resources() ? s3Resources() : null)
.add("LambdaResources", hasLambdaResources() ? lambdaResources() : null)
.add("Ec2AmiResources", hasEc2AmiResources() ? ec2AmiResources() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "S3Resources":
return Optional.ofNullable(clazz.cast(s3Resources()));
case "LambdaResources":
return Optional.ofNullable(clazz.cast(lambdaResources()));
case "Ec2AmiResources":
return Optional.ofNullable(clazz.cast(ec2AmiResources()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function