/*************************************************************************
* Copyright 2009-2013 Eucalyptus Systems, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
* Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
* CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
* additional information or have any questions.
************************************************************************/
package com.eucalyptus.cloudwatch.service.queue.metricdata;
import com.eucalyptus.cloudwatch.common.internal.domain.metricdata.MetricEntity.MetricType;
import com.eucalyptus.cloudwatch.common.internal.domain.metricdata.MetricManager;
import com.eucalyptus.cloudwatch.common.internal.domain.metricdata.SimpleMetricEntity;
import com.eucalyptus.cloudwatch.common.internal.domain.metricdata.Units;
import java.util.Date;
public class PutMetricDataAggregationKey {
private String accountId;
private String dimensionHash;
private String metricName;
private MetricType metricType;
private String namespace;
private Date timestamp;
private Units units;
public PutMetricDataAggregationKey(SimpleMetricEntity item) {
this.accountId = item.getAccountId();
this.dimensionHash = MetricManager.hash(item.getDimensionMap());
this.metricName = item.getMetricName();
this.metricType = item.getMetricType();
this.namespace = item.getNamespace();
this.timestamp = item.getTimestamp();
this.units = item.getUnits();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((accountId == null) ? 0 : accountId.hashCode());
result = prime * result
+ ((dimensionHash == null) ? 0 : dimensionHash.hashCode());
result = prime * result
+ ((metricName == null) ? 0 : metricName.hashCode());
result = prime * result
+ ((metricType == null) ? 0 : metricType.hashCode());
result = prime * result
+ ((namespace == null) ? 0 : namespace.hashCode());
result = prime * result
+ ((timestamp == null) ? 0 : timestamp.hashCode());
result = prime * result + ((units == null) ? 0 : units.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PutMetricDataAggregationKey other = (PutMetricDataAggregationKey) obj;
if (accountId == null) {
if (other.accountId != null)
return false;
} else if (!accountId.equals(other.accountId))
return false;
if (dimensionHash == null) {
if (other.dimensionHash != null)
return false;
} else if (!dimensionHash.equals(other.dimensionHash))
return false;
if (metricName == null) {
if (other.metricName != null)
return false;
} else if (!metricName.equals(other.metricName))
return false;
if (metricType != other.metricType)
return false;
if (namespace == null) {
if (other.namespace != null)
return false;
} else if (!namespace.equals(other.namespace))
return false;
if (timestamp == null) {
if (other.timestamp != null)
return false;
} else if (!timestamp.equals(other.timestamp))
return false;
if (units != other.units)
return false;
return true;
}
}