All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.snowball.model.JobResource Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Snowball module holds the client classes that are used for communicating with Amazon Snowball.

There is a newer version: 2.29.15
Show newest version
/*
 * 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 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 getter(Function g) { return obj -> g.apply((JobResource) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* An array of S3Resource objects. *

* * @param s3Resources * An array of S3Resource objects. * @return Returns a reference to this object so that method calls can be chained together. */ Builder s3Resources(Collection s3Resources); /** *

* An array of S3Resource objects. *

* * @param s3Resources * An array of S3Resource objects. * @return Returns a reference to this object so that method calls can be chained together. */ Builder s3Resources(S3Resource... s3Resources); /** *

* An array of S3Resource objects. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.snowball.model.S3Resource.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.snowball.model.S3Resource#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.snowball.model.S3Resource.Builder#build()} is called immediately and * its result is passed to {@link #s3Resources(List)}. * * @param s3Resources * a consumer that will call methods on * {@link software.amazon.awssdk.services.snowball.model.S3Resource.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #s3Resources(java.util.Collection) */ Builder s3Resources(Consumer... s3Resources); /** *

* The Python-language Lambda functions for this job. *

* * @param lambdaResources * The Python-language Lambda functions for this job. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lambdaResources(Collection lambdaResources); /** *

* The Python-language Lambda functions for this job. *

* * @param lambdaResources * The Python-language Lambda functions for this job. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lambdaResources(LambdaResource... lambdaResources); /** *

* The Python-language Lambda functions for this job. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.snowball.model.LambdaResource.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.snowball.model.LambdaResource#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.snowball.model.LambdaResource.Builder#build()} is called immediately * and its result is passed to {@link #lambdaResources(List)}. * * @param lambdaResources * a consumer that will call methods on * {@link software.amazon.awssdk.services.snowball.model.LambdaResource.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #lambdaResources(java.util.Collection) */ Builder lambdaResources(Consumer... lambdaResources); /** *

* The Amazon Machine Images (AMIs) associated with this job. *

* * @param ec2AmiResources * The Amazon Machine Images (AMIs) associated with this job. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ec2AmiResources(Collection ec2AmiResources); /** *

* The Amazon Machine Images (AMIs) associated with this job. *

* * @param ec2AmiResources * The Amazon Machine Images (AMIs) associated with this job. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ec2AmiResources(Ec2AmiResource... ec2AmiResources); /** *

* The Amazon Machine Images (AMIs) associated with this job. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.snowball.model.Ec2AmiResource.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.snowball.model.Ec2AmiResource#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.snowball.model.Ec2AmiResource.Builder#build()} is called immediately * and its result is passed to {@link #ec2AmiResources(List)}. * * @param ec2AmiResources * a consumer that will call methods on * {@link software.amazon.awssdk.services.snowball.model.Ec2AmiResource.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #ec2AmiResources(java.util.Collection) */ Builder ec2AmiResources(Consumer... ec2AmiResources); } static final class BuilderImpl implements Builder { private List s3Resources = DefaultSdkAutoConstructList.getInstance(); private List lambdaResources = DefaultSdkAutoConstructList.getInstance(); private List ec2AmiResources = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(JobResource model) { s3Resources(model.s3Resources); lambdaResources(model.lambdaResources); ec2AmiResources(model.ec2AmiResources); } public final List getS3Resources() { List result = S3ResourceListCopier.copyToBuilder(this.s3Resources); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setS3Resources(Collection s3Resources) { this.s3Resources = S3ResourceListCopier.copyFromBuilder(s3Resources); } @Override public final Builder s3Resources(Collection s3Resources) { this.s3Resources = S3ResourceListCopier.copy(s3Resources); return this; } @Override @SafeVarargs public final Builder s3Resources(S3Resource... s3Resources) { s3Resources(Arrays.asList(s3Resources)); return this; } @Override @SafeVarargs public final Builder s3Resources(Consumer... s3Resources) { s3Resources(Stream.of(s3Resources).map(c -> S3Resource.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getLambdaResources() { List result = LambdaResourceListCopier.copyToBuilder(this.lambdaResources); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setLambdaResources(Collection lambdaResources) { this.lambdaResources = LambdaResourceListCopier.copyFromBuilder(lambdaResources); } @Override public final Builder lambdaResources(Collection lambdaResources) { this.lambdaResources = LambdaResourceListCopier.copy(lambdaResources); return this; } @Override @SafeVarargs public final Builder lambdaResources(LambdaResource... lambdaResources) { lambdaResources(Arrays.asList(lambdaResources)); return this; } @Override @SafeVarargs public final Builder lambdaResources(Consumer... lambdaResources) { lambdaResources(Stream.of(lambdaResources).map(c -> LambdaResource.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getEc2AmiResources() { List result = Ec2AmiResourceListCopier.copyToBuilder(this.ec2AmiResources); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setEc2AmiResources(Collection ec2AmiResources) { this.ec2AmiResources = Ec2AmiResourceListCopier.copyFromBuilder(ec2AmiResources); } @Override public final Builder ec2AmiResources(Collection ec2AmiResources) { this.ec2AmiResources = Ec2AmiResourceListCopier.copy(ec2AmiResources); return this; } @Override @SafeVarargs public final Builder ec2AmiResources(Ec2AmiResource... ec2AmiResources) { ec2AmiResources(Arrays.asList(ec2AmiResources)); return this; } @Override @SafeVarargs public final Builder ec2AmiResources(Consumer... ec2AmiResources) { ec2AmiResources(Stream.of(ec2AmiResources).map(c -> Ec2AmiResource.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public JobResource build() { return new JobResource(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy