/** * 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 String toString() { return ToString.builder("MetricDatum").add("MetricName", metricName()).add("Dimensions", dimensions()) .add("Timestamp", timestamp()).add("Value", value()).add("StatisticValues", statisticValues()) .add("Values", values()).add("Counts", counts()).add("Unit", unitAsString()) .add("StorageResolution", storageResolution()).build(); }
/** * 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 String toString() { return ToString.builder("MetricDatum").add("MetricName", metricName()).add("Dimensions", dimensions()) .add("Timestamp", timestamp()).add("Value", value()).add("StatisticValues", statisticValues()) .add("Values", values()).add("Counts", counts()).add("Unit", unitAsString()) .add("StorageResolution", storageResolution()).build(); }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(metricName()); hashCode = 31 * hashCode + Objects.hashCode(dimensions()); hashCode = 31 * hashCode + Objects.hashCode(timestamp()); hashCode = 31 * hashCode + Objects.hashCode(value()); hashCode = 31 * hashCode + Objects.hashCode(statisticValues()); hashCode = 31 * hashCode + Objects.hashCode(values()); hashCode = 31 * hashCode + Objects.hashCode(counts()); hashCode = 31 * hashCode + Objects.hashCode(unitAsString()); hashCode = 31 * hashCode + Objects.hashCode(storageResolution()); return hashCode; }
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "MetricName": return Optional.ofNullable(clazz.cast(metricName())); case "Dimensions": return Optional.ofNullable(clazz.cast(dimensions())); case "Timestamp": return Optional.ofNullable(clazz.cast(timestamp())); case "Value": return Optional.ofNullable(clazz.cast(value())); case "StatisticValues": return Optional.ofNullable(clazz.cast(statisticValues())); case "Values": return Optional.ofNullable(clazz.cast(values())); case "Counts": return Optional.ofNullable(clazz.cast(counts())); case "Unit": return Optional.ofNullable(clazz.cast(unitAsString())); case "StorageResolution": return Optional.ofNullable(clazz.cast(storageResolution())); default: return Optional.empty(); } }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(metricName()); hashCode = 31 * hashCode + Objects.hashCode(dimensions()); hashCode = 31 * hashCode + Objects.hashCode(timestamp()); hashCode = 31 * hashCode + Objects.hashCode(value()); hashCode = 31 * hashCode + Objects.hashCode(statisticValues()); hashCode = 31 * hashCode + Objects.hashCode(values()); hashCode = 31 * hashCode + Objects.hashCode(counts()); hashCode = 31 * hashCode + Objects.hashCode(unitAsString()); hashCode = 31 * hashCode + Objects.hashCode(storageResolution()); return hashCode; }
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "MetricName": return Optional.ofNullable(clazz.cast(metricName())); case "Dimensions": return Optional.ofNullable(clazz.cast(dimensions())); case "Timestamp": return Optional.ofNullable(clazz.cast(timestamp())); case "Value": return Optional.ofNullable(clazz.cast(value())); case "StatisticValues": return Optional.ofNullable(clazz.cast(statisticValues())); case "Values": return Optional.ofNullable(clazz.cast(values())); case "Counts": return Optional.ofNullable(clazz.cast(counts())); case "Unit": return Optional.ofNullable(clazz.cast(unitAsString())); case "StorageResolution": return Optional.ofNullable(clazz.cast(storageResolution())); default: return Optional.empty(); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof MetricDatum)) { return false; } MetricDatum other = (MetricDatum) obj; return Objects.equals(metricName(), other.metricName()) && Objects.equals(dimensions(), other.dimensions()) && Objects.equals(timestamp(), other.timestamp()) && Objects.equals(value(), other.value()) && Objects.equals(statisticValues(), other.statisticValues()) && Objects.equals(values(), other.values()) && Objects.equals(counts(), other.counts()) && Objects.equals(unitAsString(), other.unitAsString()) && Objects.equals(storageResolution(), other.storageResolution()); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof MetricDatum)) { return false; } MetricDatum other = (MetricDatum) obj; return Objects.equals(metricName(), other.metricName()) && Objects.equals(dimensions(), other.dimensions()) && Objects.equals(timestamp(), other.timestamp()) && Objects.equals(value(), other.value()) && Objects.equals(statisticValues(), other.statisticValues()) && Objects.equals(values(), other.values()) && Objects.equals(counts(), other.counts()) && Objects.equals(unitAsString(), other.unitAsString()) && Objects.equals(storageResolution(), other.storageResolution()); }