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

software.amazon.awssdk.services.clouddirectory.model.CreateObjectRequest Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.30.1
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.clouddirectory.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
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.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.awscore.AwsRequestOverrideConfiguration;
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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateObjectRequest extends CloudDirectoryRequest implements
        ToCopyableBuilder {
    private static final SdkField DIRECTORY_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("DirectoryArn").getter(getter(CreateObjectRequest::directoryArn)).setter(setter(Builder::directoryArn))
            .traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-data-partition").build())
            .build();

    private static final SdkField> SCHEMA_FACETS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("SchemaFacets")
            .getter(getter(CreateObjectRequest::schemaFacets))
            .setter(setter(Builder::schemaFacets))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SchemaFacets").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(SchemaFacet::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField> OBJECT_ATTRIBUTE_LIST_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("ObjectAttributeList")
            .getter(getter(CreateObjectRequest::objectAttributeList))
            .setter(setter(Builder::objectAttributeList))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ObjectAttributeList").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(AttributeKeyAndValue::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField PARENT_REFERENCE_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("ParentReference")
            .getter(getter(CreateObjectRequest::parentReference)).setter(setter(Builder::parentReference))
            .constructor(ObjectReference::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParentReference").build()).build();

    private static final SdkField LINK_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("LinkName").getter(getter(CreateObjectRequest::linkName)).setter(setter(Builder::linkName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LinkName").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DIRECTORY_ARN_FIELD,
            SCHEMA_FACETS_FIELD, OBJECT_ATTRIBUTE_LIST_FIELD, PARENT_REFERENCE_FIELD, LINK_NAME_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();

    private final String directoryArn;

    private final List schemaFacets;

    private final List objectAttributeList;

    private final ObjectReference parentReference;

    private final String linkName;

    private CreateObjectRequest(BuilderImpl builder) {
        super(builder);
        this.directoryArn = builder.directoryArn;
        this.schemaFacets = builder.schemaFacets;
        this.objectAttributeList = builder.objectAttributeList;
        this.parentReference = builder.parentReference;
        this.linkName = builder.linkName;
    }

    /**
     * 

* The Amazon Resource Name (ARN) that is associated with the Directory in which the object will be created. * For more information, see arns. *

* * @return The Amazon Resource Name (ARN) that is associated with the Directory in which the object will be * created. For more information, see arns. */ public final String directoryArn() { return directoryArn; } /** * For responses, this returns true if the service returned a value for the SchemaFacets 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 hasSchemaFacets() { return schemaFacets != null && !(schemaFacets instanceof SdkAutoConstructList); } /** *

* A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. *

*

* 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 #hasSchemaFacets} method. *

* * @return A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. */ public final List schemaFacets() { return schemaFacets; } /** * For responses, this returns true if the service returned a value for the ObjectAttributeList 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 hasObjectAttributeList() { return objectAttributeList != null && !(objectAttributeList instanceof SdkAutoConstructList); } /** *

* The attribute map whose attribute ARN contains the key and attribute value as the map value. *

*

* 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 #hasObjectAttributeList} method. *

* * @return The attribute map whose attribute ARN contains the key and attribute value as the map value. */ public final List objectAttributeList() { return objectAttributeList; } /** *

* If specified, the parent reference to which this object will be attached. *

* * @return If specified, the parent reference to which this object will be attached. */ public final ObjectReference parentReference() { return parentReference; } /** *

* The name of link that is used to attach this object to a parent. *

* * @return The name of link that is used to attach this object to a parent. */ public final String linkName() { return linkName; } @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 + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(directoryArn()); hashCode = 31 * hashCode + Objects.hashCode(hasSchemaFacets() ? schemaFacets() : null); hashCode = 31 * hashCode + Objects.hashCode(hasObjectAttributeList() ? objectAttributeList() : null); hashCode = 31 * hashCode + Objects.hashCode(parentReference()); hashCode = 31 * hashCode + Objects.hashCode(linkName()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateObjectRequest)) { return false; } CreateObjectRequest other = (CreateObjectRequest) obj; return Objects.equals(directoryArn(), other.directoryArn()) && hasSchemaFacets() == other.hasSchemaFacets() && Objects.equals(schemaFacets(), other.schemaFacets()) && hasObjectAttributeList() == other.hasObjectAttributeList() && Objects.equals(objectAttributeList(), other.objectAttributeList()) && Objects.equals(parentReference(), other.parentReference()) && Objects.equals(linkName(), other.linkName()); } /** * 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("CreateObjectRequest").add("DirectoryArn", directoryArn()) .add("SchemaFacets", hasSchemaFacets() ? schemaFacets() : null) .add("ObjectAttributeList", hasObjectAttributeList() ? objectAttributeList() : null) .add("ParentReference", parentReference()).add("LinkName", linkName()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "DirectoryArn": return Optional.ofNullable(clazz.cast(directoryArn())); case "SchemaFacets": return Optional.ofNullable(clazz.cast(schemaFacets())); case "ObjectAttributeList": return Optional.ofNullable(clazz.cast(objectAttributeList())); case "ParentReference": return Optional.ofNullable(clazz.cast(parentReference())); case "LinkName": return Optional.ofNullable(clazz.cast(linkName())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Map> memberNameToFieldInitializer() { Map> map = new HashMap<>(); map.put("x-amz-data-partition", DIRECTORY_ARN_FIELD); map.put("SchemaFacets", SCHEMA_FACETS_FIELD); map.put("ObjectAttributeList", OBJECT_ATTRIBUTE_LIST_FIELD); map.put("ParentReference", PARENT_REFERENCE_FIELD); map.put("LinkName", LINK_NAME_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((CreateObjectRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CloudDirectoryRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The Amazon Resource Name (ARN) that is associated with the Directory in which the object will be * created. For more information, see arns. *

* * @param directoryArn * The Amazon Resource Name (ARN) that is associated with the Directory in which the object will * be created. For more information, see arns. * @return Returns a reference to this object so that method calls can be chained together. */ Builder directoryArn(String directoryArn); /** *

* A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. *

* * @param schemaFacets * A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. * @return Returns a reference to this object so that method calls can be chained together. */ Builder schemaFacets(Collection schemaFacets); /** *

* A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. *

* * @param schemaFacets * A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. * @return Returns a reference to this object so that method calls can be chained together. */ Builder schemaFacets(SchemaFacet... schemaFacets); /** *

* A list of schema facets to be associated with the object. Do not provide minor version components. See * SchemaFacet for details. *

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

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

* The attribute map whose attribute ARN contains the key and attribute value as the map value. *

* * @param objectAttributeList * The attribute map whose attribute ARN contains the key and attribute value as the map value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder objectAttributeList(Collection objectAttributeList); /** *

* The attribute map whose attribute ARN contains the key and attribute value as the map value. *

* * @param objectAttributeList * The attribute map whose attribute ARN contains the key and attribute value as the map value. * @return Returns a reference to this object so that method calls can be chained together. */ Builder objectAttributeList(AttributeKeyAndValue... objectAttributeList); /** *

* The attribute map whose attribute ARN contains the key and attribute value as the map value. *

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

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

* If specified, the parent reference to which this object will be attached. *

* * @param parentReference * If specified, the parent reference to which this object will be attached. * @return Returns a reference to this object so that method calls can be chained together. */ Builder parentReference(ObjectReference parentReference); /** *

* If specified, the parent reference to which this object will be attached. *

* This is a convenience method that creates an instance of the {@link ObjectReference.Builder} avoiding the * need to create one manually via {@link ObjectReference#builder()}. * *

* When the {@link Consumer} completes, {@link ObjectReference.Builder#build()} is called immediately and its * result is passed to {@link #parentReference(ObjectReference)}. * * @param parentReference * a consumer that will call methods on {@link ObjectReference.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #parentReference(ObjectReference) */ default Builder parentReference(Consumer parentReference) { return parentReference(ObjectReference.builder().applyMutation(parentReference).build()); } /** *

* The name of link that is used to attach this object to a parent. *

* * @param linkName * The name of link that is used to attach this object to a parent. * @return Returns a reference to this object so that method calls can be chained together. */ Builder linkName(String linkName); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CloudDirectoryRequest.BuilderImpl implements Builder { private String directoryArn; private List schemaFacets = DefaultSdkAutoConstructList.getInstance(); private List objectAttributeList = DefaultSdkAutoConstructList.getInstance(); private ObjectReference parentReference; private String linkName; private BuilderImpl() { } private BuilderImpl(CreateObjectRequest model) { super(model); directoryArn(model.directoryArn); schemaFacets(model.schemaFacets); objectAttributeList(model.objectAttributeList); parentReference(model.parentReference); linkName(model.linkName); } public final String getDirectoryArn() { return directoryArn; } public final void setDirectoryArn(String directoryArn) { this.directoryArn = directoryArn; } @Override public final Builder directoryArn(String directoryArn) { this.directoryArn = directoryArn; return this; } public final List getSchemaFacets() { List result = SchemaFacetListCopier.copyToBuilder(this.schemaFacets); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setSchemaFacets(Collection schemaFacets) { this.schemaFacets = SchemaFacetListCopier.copyFromBuilder(schemaFacets); } @Override public final Builder schemaFacets(Collection schemaFacets) { this.schemaFacets = SchemaFacetListCopier.copy(schemaFacets); return this; } @Override @SafeVarargs public final Builder schemaFacets(SchemaFacet... schemaFacets) { schemaFacets(Arrays.asList(schemaFacets)); return this; } @Override @SafeVarargs public final Builder schemaFacets(Consumer... schemaFacets) { schemaFacets(Stream.of(schemaFacets).map(c -> SchemaFacet.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getObjectAttributeList() { List result = AttributeKeyAndValueListCopier.copyToBuilder(this.objectAttributeList); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setObjectAttributeList(Collection objectAttributeList) { this.objectAttributeList = AttributeKeyAndValueListCopier.copyFromBuilder(objectAttributeList); } @Override public final Builder objectAttributeList(Collection objectAttributeList) { this.objectAttributeList = AttributeKeyAndValueListCopier.copy(objectAttributeList); return this; } @Override @SafeVarargs public final Builder objectAttributeList(AttributeKeyAndValue... objectAttributeList) { objectAttributeList(Arrays.asList(objectAttributeList)); return this; } @Override @SafeVarargs public final Builder objectAttributeList(Consumer... objectAttributeList) { objectAttributeList(Stream.of(objectAttributeList).map(c -> AttributeKeyAndValue.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final ObjectReference.Builder getParentReference() { return parentReference != null ? parentReference.toBuilder() : null; } public final void setParentReference(ObjectReference.BuilderImpl parentReference) { this.parentReference = parentReference != null ? parentReference.build() : null; } @Override public final Builder parentReference(ObjectReference parentReference) { this.parentReference = parentReference; return this; } public final String getLinkName() { return linkName; } public final void setLinkName(String linkName) { this.linkName = linkName; } @Override public final Builder linkName(String linkName) { this.linkName = linkName; return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateObjectRequest build() { return new CreateObjectRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy