software.amazon.awssdk.services.costexplorer.model.GroupDefinition Maven / Gradle / Ivy
Show all versions of cost-explorer Show documentation
/*
* Copyright 2013-2018 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.Objects;
import java.util.Optional;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.services.costexplorer.transform.GroupDefinitionMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents a group when you specify a group by criteria, or in the response to a query with a specific grouping.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class GroupDefinition implements StructuredPojo, ToCopyableBuilder {
private final String type;
private final String key;
private GroupDefinition(BuilderImpl builder) {
this.type = builder.type;
this.key = builder.key;
}
/**
*
* The string that represents the type of group.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link GroupDefinitionType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The string that represents the type of group.
* @see GroupDefinitionType
*/
public GroupDefinitionType type() {
return GroupDefinitionType.fromValue(type);
}
/**
*
* The string that represents the type of group.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link GroupDefinitionType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The string that represents the type of group.
* @see GroupDefinitionType
*/
public String typeAsString() {
return type;
}
/**
*
* The string that represents a key for a specified group.
*
*
* @return The string that represents a key for a specified group.
*/
public String key() {
return key;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(key());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GroupDefinition)) {
return false;
}
GroupDefinition other = (GroupDefinition) obj;
return Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(key(), other.key());
}
@Override
public String toString() {
return ToString.builder("GroupDefinition").add("Type", typeAsString()).add("Key", key()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "Key":
return Optional.ofNullable(clazz.cast(key()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
GroupDefinitionMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The string that represents the type of group.
*
*
* @param type
* The string that represents the type of group.
* @see GroupDefinitionType
* @return Returns a reference to this object so that method calls can be chained together.
* @see GroupDefinitionType
*/
Builder type(String type);
/**
*
* The string that represents the type of group.
*
*
* @param type
* The string that represents the type of group.
* @see GroupDefinitionType
* @return Returns a reference to this object so that method calls can be chained together.
* @see GroupDefinitionType
*/
Builder type(GroupDefinitionType type);
/**
*
* The string that represents a key for a specified group.
*
*
* @param key
* The string that represents a key for a specified group.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder key(String key);
}
static final class BuilderImpl implements Builder {
private String type;
private String key;
private BuilderImpl() {
}
private BuilderImpl(GroupDefinition model) {
type(model.type);
key(model.key);
}
public final String getType() {
return type;
}
@Override
public final Builder type(String type) {
this.type = type;
return this;
}
@Override
public final Builder type(GroupDefinitionType type) {
this.type(type.toString());
return this;
}
public final void setType(String type) {
this.type = type;
}
public final String getKey() {
return key;
}
@Override
public final Builder key(String key) {
this.key = key;
return this;
}
public final void setKey(String key) {
this.key = key;
}
@Override
public GroupDefinition build() {
return new GroupDefinition(this);
}
}
}