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

software.amazon.awssdk.services.cloudwatch.model.InsightRuleContributor Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.29.39
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.cloudwatch.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;

/**
 * 

* One of the unique contributors found by a Contributor Insights rule. If the rule contains multiple keys, then a * unique contributor is a unique combination of values from all the keys in the rule. *

*

* If the rule contains a single key, then each unique contributor is each unique value for this key. *

*

* For more information, see GetInsightRuleReport. *

*/ @Generated("software.amazon.awssdk:codegen") public final class InsightRuleContributor implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> KEYS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Keys") .getter(getter(InsightRuleContributor::keys)) .setter(setter(Builder::keys)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Keys").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField APPROXIMATE_AGGREGATE_VALUE_FIELD = SdkField. builder(MarshallingType.DOUBLE) .memberName("ApproximateAggregateValue").getter(getter(InsightRuleContributor::approximateAggregateValue)) .setter(setter(Builder::approximateAggregateValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApproximateAggregateValue").build()) .build(); private static final SdkField> DATAPOINTS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Datapoints") .getter(getter(InsightRuleContributor::datapoints)) .setter(setter(Builder::datapoints)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Datapoints").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(InsightRuleContributorDatapoint::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(KEYS_FIELD, APPROXIMATE_AGGREGATE_VALUE_FIELD, DATAPOINTS_FIELD)); private static final long serialVersionUID = 1L; private final List keys; private final Double approximateAggregateValue; private final List datapoints; private InsightRuleContributor(BuilderImpl builder) { this.keys = builder.keys; this.approximateAggregateValue = builder.approximateAggregateValue; this.datapoints = builder.datapoints; } /** * Returns true if the Keys 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 final boolean hasKeys() { return keys != null && !(keys instanceof SdkAutoConstructList); } /** *

* One of the log entry field keywords that is used to define contributors for this rule. *

*

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

*

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

* * @return One of the log entry field keywords that is used to define contributors for this rule. */ public final List keys() { return keys; } /** *

* An approximation of the aggregate value that comes from this contributor. *

* * @return An approximation of the aggregate value that comes from this contributor. */ public final Double approximateAggregateValue() { return approximateAggregateValue; } /** * Returns true if the Datapoints 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 final boolean hasDatapoints() { return datapoints != null && !(datapoints instanceof SdkAutoConstructList); } /** *

* An array of the data points where this contributor is present. Only the data points when this contributor * appeared are included in the array. *

*

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

*

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

* * @return An array of the data points where this contributor is present. Only the data points when this contributor * appeared are included in the array. */ public final List datapoints() { return datapoints; } @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(hasKeys() ? keys() : null); hashCode = 31 * hashCode + Objects.hashCode(approximateAggregateValue()); hashCode = 31 * hashCode + Objects.hashCode(hasDatapoints() ? datapoints() : 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 InsightRuleContributor)) { return false; } InsightRuleContributor other = (InsightRuleContributor) obj; return hasKeys() == other.hasKeys() && Objects.equals(keys(), other.keys()) && Objects.equals(approximateAggregateValue(), other.approximateAggregateValue()) && hasDatapoints() == other.hasDatapoints() && Objects.equals(datapoints(), other.datapoints()); } /** * 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("InsightRuleContributor").add("Keys", hasKeys() ? keys() : null) .add("ApproximateAggregateValue", approximateAggregateValue()) .add("Datapoints", hasDatapoints() ? datapoints() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Keys": return Optional.ofNullable(clazz.cast(keys())); case "ApproximateAggregateValue": return Optional.ofNullable(clazz.cast(approximateAggregateValue())); case "Datapoints": return Optional.ofNullable(clazz.cast(datapoints())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((InsightRuleContributor) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* One of the log entry field keywords that is used to define contributors for this rule. *

* * @param keys * One of the log entry field keywords that is used to define contributors for this rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keys(Collection keys); /** *

* One of the log entry field keywords that is used to define contributors for this rule. *

* * @param keys * One of the log entry field keywords that is used to define contributors for this rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keys(String... keys); /** *

* An approximation of the aggregate value that comes from this contributor. *

* * @param approximateAggregateValue * An approximation of the aggregate value that comes from this contributor. * @return Returns a reference to this object so that method calls can be chained together. */ Builder approximateAggregateValue(Double approximateAggregateValue); /** *

* An array of the data points where this contributor is present. Only the data points when this contributor * appeared are included in the array. *

* * @param datapoints * An array of the data points where this contributor is present. Only the data points when this * contributor appeared are included in the array. * @return Returns a reference to this object so that method calls can be chained together. */ Builder datapoints(Collection datapoints); /** *

* An array of the data points where this contributor is present. Only the data points when this contributor * appeared are included in the array. *

* * @param datapoints * An array of the data points where this contributor is present. Only the data points when this * contributor appeared are included in the array. * @return Returns a reference to this object so that method calls can be chained together. */ Builder datapoints(InsightRuleContributorDatapoint... datapoints); /** *

* An array of the data points where this contributor is present. Only the data points when this contributor * appeared are included in the array. *

* 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 #datapoints(List)}. * * @param datapoints * 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 #datapoints(List) */ Builder datapoints(Consumer... datapoints); } static final class BuilderImpl implements Builder { private List keys = DefaultSdkAutoConstructList.getInstance(); private Double approximateAggregateValue; private List datapoints = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(InsightRuleContributor model) { keys(model.keys); approximateAggregateValue(model.approximateAggregateValue); datapoints(model.datapoints); } public final Collection getKeys() { if (keys instanceof SdkAutoConstructList) { return null; } return keys; } @Override public final Builder keys(Collection keys) { this.keys = InsightRuleContributorKeysCopier.copy(keys); return this; } @Override @SafeVarargs public final Builder keys(String... keys) { keys(Arrays.asList(keys)); return this; } public final void setKeys(Collection keys) { this.keys = InsightRuleContributorKeysCopier.copy(keys); } public final Double getApproximateAggregateValue() { return approximateAggregateValue; } @Override public final Builder approximateAggregateValue(Double approximateAggregateValue) { this.approximateAggregateValue = approximateAggregateValue; return this; } public final void setApproximateAggregateValue(Double approximateAggregateValue) { this.approximateAggregateValue = approximateAggregateValue; } public final List getDatapoints() { List result = InsightRuleContributorDatapointsCopier .copyToBuilder(this.datapoints); if (result instanceof SdkAutoConstructList) { return null; } return result; } @Override public final Builder datapoints(Collection datapoints) { this.datapoints = InsightRuleContributorDatapointsCopier.copy(datapoints); return this; } @Override @SafeVarargs public final Builder datapoints(InsightRuleContributorDatapoint... datapoints) { datapoints(Arrays.asList(datapoints)); return this; } @Override @SafeVarargs public final Builder datapoints(Consumer... datapoints) { datapoints(Stream.of(datapoints).map(c -> InsightRuleContributorDatapoint.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setDatapoints(Collection datapoints) { this.datapoints = InsightRuleContributorDatapointsCopier.copyFromBuilder(datapoints); } @Override public InsightRuleContributor build() { return new InsightRuleContributor(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy