Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 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.cloudwatch.model;
 

The MetricDatum data type encapsulates the information sent with PutMetricData to either create a new metric or add new values to be aggregated into an existing metric.

 
 public class MetricDatum implements SerializableCloneable {

    
The name of the metric.

Constraints:
Length: 1 - 255

 
     private String metricName;

    
A list of dimensions associated with the metric.

Constraints:
Length: 0 - 10

 
The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.
 
     private java.util.Date timestamp;

    
The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>
 
     private Double value;

    
A set of statistical values describing the metric.
 
     private StatisticSet statisticValues;

    
The unit of the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

 
     private String unit;

    
The name of the metric.

Constraints:
Length: 1 - 255

Returns:
The name of the metric.
 
     public String getMetricName() {
         return ;
     }
    
    
The name of the metric.

Constraints:
Length: 1 - 255

Parameters:
metricName The name of the metric.
 
     public void setMetricName(String metricName) {
         this. = metricName;
     }
    
    
The name of the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 - 255

Parameters:
metricName The name of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public MetricDatum withMetricName(String metricName) {
        this. = metricName;
        return this;
    }

    
A list of dimensions associated with the metric.

Constraints:
Length: 0 - 10

Returns:
A list of dimensions associated with the metric.
    public java.util.List<DimensiongetDimensions() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<Dimension>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
A list of dimensions associated with the metric.

Constraints:
Length: 0 - 10

Parameters:
dimensions A list of dimensions associated with the metric.
    public void setDimensions(java.util.Collection<Dimensiondimensions) {
        if (dimensions == null) {
            this. = null;
            return;
        }
        dimensionsCopy.addAll(dimensions);
        this. = dimensionsCopy;
    }
    
    
A list of dimensions associated with the metric.

NOTE: This method appends the values to the existing list (if any). Use setDimensions(java.util.Collection) or withDimensions(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 0 - 10

Parameters:
dimensions A list of dimensions associated with the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public MetricDatum withDimensions(Dimension... dimensions) {
        if (getDimensions() == nullsetDimensions(new java.util.ArrayList<Dimension>(dimensions.length));
        for (Dimension value : dimensions) {
            getDimensions().add(value);
        }
        return this;
    }
    
    
A list of dimensions associated with the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 0 - 10

Parameters:
dimensions A list of dimensions associated with the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public MetricDatum withDimensions(java.util.Collection<Dimensiondimensions) {
        if (dimensions == null) {
            this. = null;
        } else {
            dimensionsCopy.addAll(dimensions);
            this. = dimensionsCopy;
        }
        return this;
    }

    
The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.

Returns:
The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.
    public java.util.Date getTimestamp() {
        return ;
    }
    
    
The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.

Parameters:
timestamp The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.
    public void setTimestamp(java.util.Date timestamp) {
        this. = timestamp;
    }
    
    
The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.

Returns a reference to this object so that method calls can be chained together.

Parameters:
timestamp The time stamp used for the metric. If not specified, the default value is set to the time the metric data was received.
Returns:
A reference to this updated object so that method calls can be chained together.
    public MetricDatum withTimestamp(java.util.Date timestamp) {
        this. = timestamp;
        return this;
    }

    
The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>

Returns:
The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>
    public Double getValue() {
        return ;
    }
    
    
The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>

Parameters:
value The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>
    public void setValue(Double value) {
        this. = value;
    }
    
    
The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>

Returns a reference to this object so that method calls can be chained together.

Parameters:
value The value for the metric. <important>Although the Value parameter accepts numbers of type Double, Amazon CloudWatch truncates values with very large exponents. Values with base-10 exponents greater than 126 (1 x 10^126) are truncated. Likewise, values with base-10 exponents less than -130 (1 x 10^-130) are also truncated. </important>
Returns:
A reference to this updated object so that method calls can be chained together.
    public MetricDatum withValue(Double value) {
        this. = value;
        return this;
    }

    
A set of statistical values describing the metric.

Returns:
A set of statistical values describing the metric.
    public StatisticSet getStatisticValues() {
        return ;
    }
    
    
A set of statistical values describing the metric.

Parameters:
statisticValues A set of statistical values describing the metric.
    public void setStatisticValues(StatisticSet statisticValues) {
        this. = statisticValues;
    }
    
    
A set of statistical values describing the metric.

Returns a reference to this object so that method calls can be chained together.

Parameters:
statisticValues A set of statistical values describing the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
    public MetricDatum withStatisticValues(StatisticSet statisticValues) {
        this. = statisticValues;
        return this;
    }

    
The unit of the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Returns:
The unit of the metric.
See also:
StandardUnit
    public String getUnit() {
        return ;
    }
    
    
The unit of the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit of the metric.
See also:
StandardUnit
    public void setUnit(String unit) {
        this. = unit;
    }
    
    
The unit of the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
StandardUnit
    public MetricDatum withUnit(String unit) {
        this. = unit;
        return this;
    }

    
The unit of the metric.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit of the metric.
See also:
StandardUnit
    public void setUnit(StandardUnit unit) {
        this. = unit.toString();
    }
    
    
The unit of the metric.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, Gigabits, Terabits, Percent, Count, Bytes/Second, Kilobytes/Second, Megabytes/Second, Gigabytes/Second, Terabytes/Second, Bits/Second, Kilobits/Second, Megabits/Second, Gigabits/Second, Terabits/Second, Count/Second, None

Parameters:
unit The unit of the metric.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
StandardUnit
    public MetricDatum withUnit(StandardUnit unit) {
        this. = unit.toString();
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getMetricName() != nullsb.append("MetricName: " + getMetricName() + ",");
        if (getDimensions() != nullsb.append("Dimensions: " + getDimensions() + ",");
        if (getTimestamp() != nullsb.append("Timestamp: " + getTimestamp() + ",");
        if (getValue() != nullsb.append("Value: " + getValue() + ",");
        if (getStatisticValues() != nullsb.append("StatisticValues: " + getStatisticValues() + ",");
        if (getUnit() != nullsb.append("Unit: " + getUnit() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getMetricName() == null) ? 0 : getMetricName().hashCode()); 
        hashCode = prime * hashCode + ((getDimensions() == null) ? 0 : getDimensions().hashCode()); 
        hashCode = prime * hashCode + ((getTimestamp() == null) ? 0 : getTimestamp().hashCode()); 
        hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); 
        hashCode = prime * hashCode + ((getStatisticValues() == null) ? 0 : getStatisticValues().hashCode()); 
        hashCode = prime * hashCode + ((getUnit() == null) ? 0 : getUnit().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof MetricDatum == falsereturn false;
        MetricDatum other = (MetricDatum)obj;
        
        if (other.getMetricName() == null ^ this.getMetricName() == nullreturn false;
        if (other.getMetricName() != null && other.getMetricName().equals(this.getMetricName()) == falsereturn false
        if (other.getDimensions() == null ^ this.getDimensions() == nullreturn false;
        if (other.getDimensions() != null && other.getDimensions().equals(this.getDimensions()) == falsereturn false
        if (other.getTimestamp() == null ^ this.getTimestamp() == nullreturn false;
        if (other.getTimestamp() != null && other.getTimestamp().equals(this.getTimestamp()) == falsereturn false
        if (other.getValue() == null ^ this.getValue() == nullreturn false;
        if (other.getValue() != null && other.getValue().equals(this.getValue()) == falsereturn false
        if (other.getStatisticValues() == null ^ this.getStatisticValues() == nullreturn false;
        if (other.getStatisticValues() != null && other.getStatisticValues().equals(this.getStatisticValues()) == falsereturn false
        if (other.getUnit() == null ^ this.getUnit() == nullreturn false;
        if (other.getUnit() != null && other.getUnit().equals(this.getUnit()) == falsereturn false
        return true;
    }
    
    @Override
    public MetricDatum clone() {
        try {
            return (MetricDatumsuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X