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

software.amazon.awssdk.services.costexplorer.model.GetAnomalySubscriptionsResponse 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.costexplorer.model;

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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class GetAnomalySubscriptionsResponse extends CostExplorerResponse implements
        ToCopyableBuilder {
    private static final SdkField> ANOMALY_SUBSCRIPTIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("AnomalySubscriptions")
            .getter(getter(GetAnomalySubscriptionsResponse::anomalySubscriptions))
            .setter(setter(Builder::anomalySubscriptions))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AnomalySubscriptions").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(AnomalySubscription::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField NEXT_PAGE_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("NextPageToken").getter(getter(GetAnomalySubscriptionsResponse::nextPageToken))
            .setter(setter(Builder::nextPageToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextPageToken").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ANOMALY_SUBSCRIPTIONS_FIELD,
            NEXT_PAGE_TOKEN_FIELD));

    private final List anomalySubscriptions;

    private final String nextPageToken;

    private GetAnomalySubscriptionsResponse(BuilderImpl builder) {
        super(builder);
        this.anomalySubscriptions = builder.anomalySubscriptions;
        this.nextPageToken = builder.nextPageToken;
    }

    /**
     * Returns true if the AnomalySubscriptions property was specified by the sender (it may be empty), or false if the
     * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
     * service.
     */
    public boolean hasAnomalySubscriptions() {
        return anomalySubscriptions != null && !(anomalySubscriptions instanceof SdkAutoConstructList);
    }

    /**
     * 

* A list of cost anomaly subscriptions that includes the detailed metadata for each one. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasAnomalySubscriptions()} to see if a value was sent in this field. *

* * @return A list of cost anomaly subscriptions that includes the detailed metadata for each one. */ public List anomalySubscriptions() { return anomalySubscriptions; } /** *

* The token to retrieve the next set of results. AWS provides the token when the response from a previous call has * more results than the maximum page size. *

* * @return The token to retrieve the next set of results. AWS provides the token when the response from a previous * call has more results than the maximum page size. */ public String nextPageToken() { return nextPageToken; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(hasAnomalySubscriptions() ? anomalySubscriptions() : null); hashCode = 31 * hashCode + Objects.hashCode(nextPageToken()); return hashCode; } @Override public boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GetAnomalySubscriptionsResponse)) { return false; } GetAnomalySubscriptionsResponse other = (GetAnomalySubscriptionsResponse) obj; return hasAnomalySubscriptions() == other.hasAnomalySubscriptions() && Objects.equals(anomalySubscriptions(), other.anomalySubscriptions()) && Objects.equals(nextPageToken(), other.nextPageToken()); } /** * 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 String toString() { return ToString.builder("GetAnomalySubscriptionsResponse") .add("AnomalySubscriptions", hasAnomalySubscriptions() ? anomalySubscriptions() : null) .add("NextPageToken", nextPageToken()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AnomalySubscriptions": return Optional.ofNullable(clazz.cast(anomalySubscriptions())); case "NextPageToken": return Optional.ofNullable(clazz.cast(nextPageToken())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GetAnomalySubscriptionsResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CostExplorerResponse.Builder, SdkPojo, CopyableBuilder { /** *

* A list of cost anomaly subscriptions that includes the detailed metadata for each one. *

* * @param anomalySubscriptions * A list of cost anomaly subscriptions that includes the detailed metadata for each one. * @return Returns a reference to this object so that method calls can be chained together. */ Builder anomalySubscriptions(Collection anomalySubscriptions); /** *

* A list of cost anomaly subscriptions that includes the detailed metadata for each one. *

* * @param anomalySubscriptions * A list of cost anomaly subscriptions that includes the detailed metadata for each one. * @return Returns a reference to this object so that method calls can be chained together. */ Builder anomalySubscriptions(AnomalySubscription... anomalySubscriptions); /** *

* A list of cost anomaly subscriptions that includes the detailed metadata for each one. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the * need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately * and its result is passed to {@link #anomalySubscriptions(List)}. * * @param anomalySubscriptions * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #anomalySubscriptions(List) */ Builder anomalySubscriptions(Consumer... anomalySubscriptions); /** *

* The token to retrieve the next set of results. AWS provides the token when the response from a previous call * has more results than the maximum page size. *

* * @param nextPageToken * The token to retrieve the next set of results. AWS provides the token when the response from a * previous call has more results than the maximum page size. * @return Returns a reference to this object so that method calls can be chained together. */ Builder nextPageToken(String nextPageToken); } static final class BuilderImpl extends CostExplorerResponse.BuilderImpl implements Builder { private List anomalySubscriptions = DefaultSdkAutoConstructList.getInstance(); private String nextPageToken; private BuilderImpl() { } private BuilderImpl(GetAnomalySubscriptionsResponse model) { super(model); anomalySubscriptions(model.anomalySubscriptions); nextPageToken(model.nextPageToken); } public final Collection getAnomalySubscriptions() { if (anomalySubscriptions instanceof SdkAutoConstructList) { return null; } return anomalySubscriptions != null ? anomalySubscriptions.stream().map(AnomalySubscription::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder anomalySubscriptions(Collection anomalySubscriptions) { this.anomalySubscriptions = AnomalySubscriptionsCopier.copy(anomalySubscriptions); return this; } @Override @SafeVarargs public final Builder anomalySubscriptions(AnomalySubscription... anomalySubscriptions) { anomalySubscriptions(Arrays.asList(anomalySubscriptions)); return this; } @Override @SafeVarargs public final Builder anomalySubscriptions(Consumer... anomalySubscriptions) { anomalySubscriptions(Stream.of(anomalySubscriptions).map(c -> AnomalySubscription.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setAnomalySubscriptions(Collection anomalySubscriptions) { this.anomalySubscriptions = AnomalySubscriptionsCopier.copyFromBuilder(anomalySubscriptions); } public final String getNextPageToken() { return nextPageToken; } @Override public final Builder nextPageToken(String nextPageToken) { this.nextPageToken = nextPageToken; return this; } public final void setNextPageToken(String nextPageToken) { this.nextPageToken = nextPageToken; } @Override public GetAnomalySubscriptionsResponse build() { return new GetAnomalySubscriptionsResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy