software.amazon.awssdk.services.costexplorer.model.DimensionValues Maven / Gradle / Ivy
Show all versions of costexplorer Show documentation
/*
* 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.beans.Transient;
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.Function;
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 metadata that you can use to filter and group your results. You can use GetDimensionValues
to find
* specific values.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DimensionValues implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField KEY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Key")
.getter(getter(DimensionValues::keyAsString)).setter(setter(Builder::key))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Key").build()).build();
private static final SdkField> VALUES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Values")
.getter(getter(DimensionValues::values))
.setter(setter(Builder::values))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Values").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> MATCH_OPTIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("MatchOptions")
.getter(getter(DimensionValues::matchOptionsAsStrings))
.setter(setter(Builder::matchOptionsWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchOptions").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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(KEY_FIELD, VALUES_FIELD,
MATCH_OPTIONS_FIELD));
private static final long serialVersionUID = 1L;
private final String key;
private final List values;
private final List matchOptions;
private DimensionValues(BuilderImpl builder) {
this.key = builder.key;
this.values = builder.values;
this.matchOptions = builder.matchOptions;
}
/**
*
* The names of the metadata types that you can use to filter and group your results. For example, AZ
* returns a list of Availability Zones.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #key} will return
* {@link Dimension#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #keyAsString}.
*
*
* @return The names of the metadata types that you can use to filter and group your results. For example,
* AZ
returns a list of Availability Zones.
* @see Dimension
*/
public final Dimension key() {
return Dimension.fromValue(key);
}
/**
*
* The names of the metadata types that you can use to filter and group your results. For example, AZ
* returns a list of Availability Zones.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #key} will return
* {@link Dimension#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #keyAsString}.
*
*
* @return The names of the metadata types that you can use to filter and group your results. For example,
* AZ
returns a list of Availability Zones.
* @see Dimension
*/
public final String keyAsString() {
return key;
}
/**
* Returns true if the Values 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 hasValues() {
return values != null && !(values instanceof SdkAutoConstructList);
}
/**
*
* The metadata values that you can use to filter and group your results. You can use
* GetDimensionValues
to find specific values.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasValues()} to see if a value was sent in this field.
*
*
* @return The metadata values that you can use to filter and group your results. You can use
* GetDimensionValues
to find specific values.
*/
public final List values() {
return values;
}
/**
*
* The match options that you can use to filter your results. MatchOptions
is only applicable for
* actions related to Cost Category. The default values for MatchOptions
are EQUALS
and
* CASE_SENSITIVE
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasMatchOptions()} to see if a value was sent in this field.
*
*
* @return The match options that you can use to filter your results. MatchOptions
is only applicable
* for actions related to Cost Category. The default values for MatchOptions
are
* EQUALS
and CASE_SENSITIVE
.
*/
public final List matchOptions() {
return MatchOptionsCopier.copyStringToEnum(matchOptions);
}
/**
* Returns true if the MatchOptions 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 hasMatchOptions() {
return matchOptions != null && !(matchOptions instanceof SdkAutoConstructList);
}
/**
*
* The match options that you can use to filter your results. MatchOptions
is only applicable for
* actions related to Cost Category. The default values for MatchOptions
are EQUALS
and
* CASE_SENSITIVE
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasMatchOptions()} to see if a value was sent in this field.
*
*
* @return The match options that you can use to filter your results. MatchOptions
is only applicable
* for actions related to Cost Category. The default values for MatchOptions
are
* EQUALS
and CASE_SENSITIVE
.
*/
public final List matchOptionsAsStrings() {
return matchOptions;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(keyAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasValues() ? values() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasMatchOptions() ? matchOptionsAsStrings() : 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 DimensionValues)) {
return false;
}
DimensionValues other = (DimensionValues) obj;
return Objects.equals(keyAsString(), other.keyAsString()) && hasValues() == other.hasValues()
&& Objects.equals(values(), other.values()) && hasMatchOptions() == other.hasMatchOptions()
&& Objects.equals(matchOptionsAsStrings(), other.matchOptionsAsStrings());
}
/**
* 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("DimensionValues").add("Key", keyAsString()).add("Values", hasValues() ? values() : null)
.add("MatchOptions", hasMatchOptions() ? matchOptionsAsStrings() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Key":
return Optional.ofNullable(clazz.cast(keyAsString()));
case "Values":
return Optional.ofNullable(clazz.cast(values()));
case "MatchOptions":
return Optional.ofNullable(clazz.cast(matchOptionsAsStrings()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function