/** * <p> * The unit to use for the returned data points. * </p> * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. * </p> * * @return The unit to use for the returned data points. * @see StandardUnit */ public StandardUnit unit() { return StandardUnit.fromValue(unit); }
/** * Use this in place of valueOf to convert the raw string returned by the service into the enum value. * * @param value * real value * @return StandardUnit corresponding to the value */ public static StandardUnit fromValue(String value) { if (value == null) { return null; } return Stream.of(StandardUnit.values()).filter(e -> e.toString().equals(value)).findFirst() .orElse(UNKNOWN_TO_SDK_VERSION); }
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }
private void accumulate(MetricDatumWithKey<KeyType> metricDatumWithKey, MetricDatum newDatum) { MetricDatum oldDatum = metricDatumWithKey.datum; if (!oldDatum.unit().equals(newDatum.unit())) { throw new IllegalArgumentException("Unit mismatch for datum named " + oldDatum.metricName()); } StatisticSet oldStats = oldDatum.statisticValues(); StatisticSet newStats = newDatum.statisticValues(); StatisticSet statisticSet = oldStats.toBuilder().sum(oldStats.sum() + newStats.sum()) .minimum(Math.min(oldStats.minimum(), newStats.minimum())) .maximum(Math.max(oldStats.maximum(), newStats.maximum())) .sampleCount(oldStats.sampleCount() + newStats.sampleCount()).build(); MetricDatum datum = oldDatum.toBuilder().statisticValues(statisticSet).build(); metricDatumWithKey.datum(datum); } }
/** * Use this in place of {@link #values()} to return a {@link Set} of all values known to the SDK. This will return * all known enum values except {@link #UNKNOWN_TO_SDK_VERSION}. * * @return a {@link Set} of known {@link StandardUnit}s */ public static Set<StandardUnit> knownValues() { return Stream.of(values()).filter(v -> v != UNKNOWN_TO_SDK_VERSION).collect(toSet()); } }
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }
private void accumulate(MetricDatumWithKey<KeyType> metricDatumWithKey, MetricDatum newDatum) { MetricDatum oldDatum = metricDatumWithKey.datum; if (!oldDatum.unit().equals(newDatum.unit())) { throw new IllegalArgumentException("Unit mismatch for datum named " + oldDatum.metricName()); } StatisticSet oldStats = oldDatum.statisticValues(); StatisticSet newStats = newDatum.statisticValues(); StatisticSet statisticSet = oldStats.toBuilder().sum(oldStats.sum() + newStats.sum()) .minimum(Math.min(oldStats.minimum(), newStats.minimum())) .maximum(Math.max(oldStats.maximum(), newStats.maximum())) .sampleCount(oldStats.sampleCount() + newStats.sampleCount()).build(); MetricDatum datum = oldDatum.toBuilder().statisticValues(statisticSet).build(); metricDatumWithKey.datum(datum); } }
/** * Use this in place of {@link #values()} to return a {@link Set} of all values known to the SDK. This will return * all known enum values except {@link #UNKNOWN_TO_SDK_VERSION}. * * @return a {@link Set} of known {@link StandardUnit}s */ public static Set<StandardUnit> knownValues() { return Stream.of(values()).filter(v -> v != UNKNOWN_TO_SDK_VERSION).collect(toSet()); } }
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }
/** * <p> * The unit of the metric associated with the alarm. * </p> * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. * </p> * * @return The unit of the metric associated with the alarm. * @see StandardUnit */ public StandardUnit unit() { return StandardUnit.fromValue(unit); }
/** * Use this in place of valueOf to convert the raw string returned by the service into the enum value. * * @param value * real value * @return StandardUnit corresponding to the value */ public static StandardUnit fromValue(String value) { if (value == null) { return null; } return Stream.of(StandardUnit.values()).filter(e -> e.toString().equals(value)).findFirst() .orElse(UNKNOWN_TO_SDK_VERSION); }
.build(); } else { if (!datum.unit().equals(unit)) { throw new IllegalArgumentException("Cannot add to existing metric with different unit");
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }
/** * <p> * The unit of the metric. * </p> * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. * </p> * * @return The unit of the metric. * @see StandardUnit */ public StandardUnit unit() { return StandardUnit.fromValue(unit); }
.build(); } else { if (!datum.unit().equals(unit)) { throw new IllegalArgumentException("Cannot add to existing metric with different unit");
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }
/** * <p> * The standard unit for the data point. * </p> * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. * </p> * * @return The standard unit for the data point. * @see StandardUnit */ public StandardUnit unit() { return StandardUnit.fromValue(unit); }
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }
/** * <p> * The unit for the metric. * </p> * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #unit} will return * {@link StandardUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #unitAsString}. * </p> * * @return The unit for the metric. * @see StandardUnit */ public StandardUnit unit() { return StandardUnit.fromValue(unit); }
@Override public final Builder unit(StandardUnit unit) { this.unit(unit.toString()); return this; }