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

software.amazon.awssdk.services.managedblockchain.model.ProposalActions 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.managedblockchain.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;

/**
 * 

* The actions to carry out if a proposal is APPROVED. *

*

* Applies only to Hyperledger Fabric. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ProposalActions implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> INVITATIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Invitations") .getter(getter(ProposalActions::invitations)) .setter(setter(Builder::invitations)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Invitations").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(InviteAction::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> REMOVALS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Removals") .getter(getter(ProposalActions::removals)) .setter(setter(Builder::removals)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Removals").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(RemoveAction::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INVITATIONS_FIELD, REMOVALS_FIELD)); private static final long serialVersionUID = 1L; private final List invitations; private final List removals; private ProposalActions(BuilderImpl builder) { this.invitations = builder.invitations; this.removals = builder.removals; } /** * For responses, this returns true if the service returned a value for the Invitations 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 hasInvitations() { return invitations != null && !(invitations instanceof SdkAutoConstructList); } /** *

* The actions to perform for an APPROVED proposal to invite an AWS account to create a member and join * the network. *

*

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

* * @return The actions to perform for an APPROVED proposal to invite an AWS account to create a member * and join the network. */ public final List invitations() { return invitations; } /** * For responses, this returns true if the service returned a value for the Removals 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 hasRemovals() { return removals != null && !(removals instanceof SdkAutoConstructList); } /** *

* The actions to perform for an APPROVED proposal to remove a member from the network, which deletes * the member and all associated member resources from the network. *

*

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

* * @return The actions to perform for an APPROVED proposal to remove a member from the network, which * deletes the member and all associated member resources from the network. */ public final List removals() { return removals; } @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(hasInvitations() ? invitations() : null); hashCode = 31 * hashCode + Objects.hashCode(hasRemovals() ? removals() : 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 ProposalActions)) { return false; } ProposalActions other = (ProposalActions) obj; return hasInvitations() == other.hasInvitations() && Objects.equals(invitations(), other.invitations()) && hasRemovals() == other.hasRemovals() && Objects.equals(removals(), other.removals()); } /** * 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("ProposalActions").add("Invitations", hasInvitations() ? invitations() : null) .add("Removals", hasRemovals() ? removals() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Invitations": return Optional.ofNullable(clazz.cast(invitations())); case "Removals": return Optional.ofNullable(clazz.cast(removals())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ProposalActions) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The actions to perform for an APPROVED proposal to invite an AWS account to create a member and * join the network. *

* * @param invitations * The actions to perform for an APPROVED proposal to invite an AWS account to create a * member and join the network. * @return Returns a reference to this object so that method calls can be chained together. */ Builder invitations(Collection invitations); /** *

* The actions to perform for an APPROVED proposal to invite an AWS account to create a member and * join the network. *

* * @param invitations * The actions to perform for an APPROVED proposal to invite an AWS account to create a * member and join the network. * @return Returns a reference to this object so that method calls can be chained together. */ Builder invitations(InviteAction... invitations); /** *

* The actions to perform for an APPROVED proposal to invite an AWS account to create a member and * join the network. *

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

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

* The actions to perform for an APPROVED proposal to remove a member from the network, which * deletes the member and all associated member resources from the network. *

* * @param removals * The actions to perform for an APPROVED proposal to remove a member from the network, * which deletes the member and all associated member resources from the network. * @return Returns a reference to this object so that method calls can be chained together. */ Builder removals(Collection removals); /** *

* The actions to perform for an APPROVED proposal to remove a member from the network, which * deletes the member and all associated member resources from the network. *

* * @param removals * The actions to perform for an APPROVED proposal to remove a member from the network, * which deletes the member and all associated member resources from the network. * @return Returns a reference to this object so that method calls can be chained together. */ Builder removals(RemoveAction... removals); /** *

* The actions to perform for an APPROVED proposal to remove a member from the network, which * deletes the member and all associated member resources from the network. *

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

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.managedblockchain.model.RemoveAction.Builder#build()} is called * immediately and its result is passed to {@link #removals(List)}. * * @param removals * a consumer that will call methods on * {@link software.amazon.awssdk.services.managedblockchain.model.RemoveAction.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #removals(java.util.Collection) */ Builder removals(Consumer... removals); } static final class BuilderImpl implements Builder { private List invitations = DefaultSdkAutoConstructList.getInstance(); private List removals = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(ProposalActions model) { invitations(model.invitations); removals(model.removals); } public final List getInvitations() { List result = InviteActionListCopier.copyToBuilder(this.invitations); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setInvitations(Collection invitations) { this.invitations = InviteActionListCopier.copyFromBuilder(invitations); } @Override public final Builder invitations(Collection invitations) { this.invitations = InviteActionListCopier.copy(invitations); return this; } @Override @SafeVarargs public final Builder invitations(InviteAction... invitations) { invitations(Arrays.asList(invitations)); return this; } @Override @SafeVarargs public final Builder invitations(Consumer... invitations) { invitations(Stream.of(invitations).map(c -> InviteAction.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getRemovals() { List result = RemoveActionListCopier.copyToBuilder(this.removals); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setRemovals(Collection removals) { this.removals = RemoveActionListCopier.copyFromBuilder(removals); } @Override public final Builder removals(Collection removals) { this.removals = RemoveActionListCopier.copy(removals); return this; } @Override @SafeVarargs public final Builder removals(RemoveAction... removals) { removals(Arrays.asList(removals)); return this; } @Override @SafeVarargs public final Builder removals(Consumer... removals) { removals(Stream.of(removals).map(c -> RemoveAction.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public ProposalActions build() { return new ProposalActions(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy