
com.amazonaws.services.costexplorer.model.Group Maven / Gradle / Ivy
Show all versions of aws-java-sdk-costexplorer Show documentation
/*
* Copyright 2020-2025 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 com.amazonaws.services.costexplorer.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* One level of grouped data in the results.
*
*
* @see AWS API Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Group implements Serializable, Cloneable, StructuredPojo {
/**
*
* The keys that are included in this group.
*
*/
private java.util.List keys;
/**
*
* The metrics that are included in this group.
*
*/
private java.util.Map metrics;
/**
*
* The keys that are included in this group.
*
*
* @return The keys that are included in this group.
*/
public java.util.List getKeys() {
return keys;
}
/**
*
* The keys that are included in this group.
*
*
* @param keys
* The keys that are included in this group.
*/
public void setKeys(java.util.Collection keys) {
if (keys == null) {
this.keys = null;
return;
}
this.keys = new java.util.ArrayList(keys);
}
/**
*
* The keys that are included in this group.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setKeys(java.util.Collection)} or {@link #withKeys(java.util.Collection)} if you want to override the
* existing values.
*
*
* @param keys
* The keys that are included in this group.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Group withKeys(String... keys) {
if (this.keys == null) {
setKeys(new java.util.ArrayList(keys.length));
}
for (String ele : keys) {
this.keys.add(ele);
}
return this;
}
/**
*
* The keys that are included in this group.
*
*
* @param keys
* The keys that are included in this group.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Group withKeys(java.util.Collection keys) {
setKeys(keys);
return this;
}
/**
*
* The metrics that are included in this group.
*
*
* @return The metrics that are included in this group.
*/
public java.util.Map getMetrics() {
return metrics;
}
/**
*
* The metrics that are included in this group.
*
*
* @param metrics
* The metrics that are included in this group.
*/
public void setMetrics(java.util.Map metrics) {
this.metrics = metrics;
}
/**
*
* The metrics that are included in this group.
*
*
* @param metrics
* The metrics that are included in this group.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Group withMetrics(java.util.Map metrics) {
setMetrics(metrics);
return this;
}
/**
* Add a single Metrics entry
*
* @see Group#withMetrics
* @returns a reference to this object so that method calls can be chained together.
*/
public Group addMetricsEntry(String key, MetricValue value) {
if (null == this.metrics) {
this.metrics = new java.util.HashMap();
}
if (this.metrics.containsKey(key))
throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
this.metrics.put(key, value);
return this;
}
/**
* Removes all the entries added into Metrics.
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Group clearMetricsEntries() {
this.metrics = null;
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getKeys() != null)
sb.append("Keys: ").append(getKeys()).append(",");
if (getMetrics() != null)
sb.append("Metrics: ").append(getMetrics());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Group == false)
return false;
Group other = (Group) obj;
if (other.getKeys() == null ^ this.getKeys() == null)
return false;
if (other.getKeys() != null && other.getKeys().equals(this.getKeys()) == false)
return false;
if (other.getMetrics() == null ^ this.getMetrics() == null)
return false;
if (other.getMetrics() != null && other.getMetrics().equals(this.getMetrics()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getKeys() == null) ? 0 : getKeys().hashCode());
hashCode = prime * hashCode + ((getMetrics() == null) ? 0 : getMetrics().hashCode());
return hashCode;
}
@Override
public Group clone() {
try {
return (Group) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.costexplorer.model.transform.GroupMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}