// Path: metrics/src/main/java/com/google/monitoring/metrics/Metric.java
// public interface Metric<V> {
// 
//   /**
//    * Returns the latest {@link MetricPoint} instances for every label-value combination tracked for
//    * this metric.
//    */
//   ImmutableList<MetricPoint<V>> getTimestampedValues();
// 
//   /** Returns the count of values being stored with this metric. */
//   int getCardinality();
// 
//   /** Returns the schema of this metric. */
//   MetricSchema getMetricSchema();
// 
//   /**
//    * Returns the type for the value of this metric, which would otherwise be erased at compile-time.
//    * This is useful for implementors of {@link MetricWriter}.
//    */
//   Class<V> getValueClass();
// }
// 
// Path: metrics/src/main/java/com/google/monitoring/metrics/MetricPoint.java
// @AutoValue
// public abstract class MetricPoint<V> implements Comparable<MetricPoint<V>> {
// 
//   /**
//    * Returns a new {@link MetricPoint} representing a value at a specific {@link Instant}.
//    *
//    * <p>Callers should insure that the count of {@code labelValues} matches the count of labels for
//    * the given metric.
//    */
//   @VisibleForTesting
//   public static <V> MetricPoint<V> create(
//       Metric<V> metric, ImmutableList<String> labelValues, Instant timestamp, V value) {
//     MetricsUtils.checkLabelValuesLength(metric, labelValues);
// 
//     return new AutoValue_MetricPoint<>(
//         metric, labelValues, Range.openClosed(timestamp, timestamp), value);
//   }
// 
//   /**
//    * Returns a new {@link MetricPoint} representing a value over an {@link Range} from {@code
//    * startTime} to {@code endTime}.
//    *
//    * <p>Callers should insure that the count of {@code labelValues} matches the count of labels for
//    * the given metric.
//    */
//   @VisibleForTesting
//   public static <V> MetricPoint<V> create(
//       Metric<V> metric,
//       ImmutableList<String> labelValues,
//       Instant startTime,
//       Instant endTime,
//       V value) {
//     MetricsUtils.checkLabelValuesLength(metric, labelValues);
// 
//     return new AutoValue_MetricPoint<>(
//         metric, labelValues, Range.openClosed(startTime, endTime), value);
//   }
// 
//   public abstract Metric<V> metric();
// 
//   public abstract ImmutableList<String> labelValues();
// 
//   public abstract Range<Instant> interval();
// 
//   public abstract V value();
// 
//   @Override
//   public int compareTo(MetricPoint<V> other) {
//     int minLength = Math.min(this.labelValues().size(), other.labelValues().size());
//     for (int index = 0; index < minLength; index++) {
//       int comparisonResult =
//           this.labelValues().get(index).compareTo(other.labelValues().get(index));
//       if (comparisonResult != 0) {
//         return comparisonResult;
//       }
//     }
//     return Integer.compare(this.labelValues().size(), other.labelValues().size());
//   }
// }


import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
import com.google.monitoring.metrics.Metric;
import com.google.monitoring.metrics.MetricPoint;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nullable;
// Copyright 2017 Google LLC. 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.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.google.monitoring.metrics.contrib;



/**
 * Base truth subject for asserting things about {@link Metric} instances.
 *
 * <p>For use with the Google <a href="https://google.github.io/truth/">Truth</a> framework.
 */
abstract class AbstractMetricSubject<T, S extends AbstractMetricSubject<T, S>>
    extends Subject<S, Metric<T>> {

  /** And chainer to allow fluent assertions. */
  public static class And<S extends AbstractMetricSubject<?, S>> {

    private final S subject;

    And(S subject) {
      this.subject = subject;
    }

    public S and() {
      return subject;
    }
  }

  @SuppressWarnings("unchecked")
  And<S> andChainer() {
    return new And<>((S) this);
  }

  /**
   * List of label value tuples about which an assertion has been made so far.
   *
   * <p>Used to track what tuples have been seen, in order to support hasNoOtherValues() assertions.
   */
  protected final Set<ImmutableList<String>> expectedNondefaultLabelTuples = new HashSet<>();

  /**
   * Function to convert a metric point to a nice string representation for use in error messages.
   */
// Path: metrics/src/main/java/com/google/monitoring/metrics/Metric.java
// public interface Metric<V> {
// 
//   /**
//    * Returns the latest {@link MetricPoint} instances for every label-value combination tracked for
//    * this metric.
//    */
//   ImmutableList<MetricPoint<V>> getTimestampedValues();
// 
//   /** Returns the count of values being stored with this metric. */
//   int getCardinality();
// 
//   /** Returns the schema of this metric. */
//   MetricSchema getMetricSchema();
// 
//   /**
//    * Returns the type for the value of this metric, which would otherwise be erased at compile-time.
//    * This is useful for implementors of {@link MetricWriter}.
//    */
//   Class<V> getValueClass();
// }
// 
// Path: metrics/src/main/java/com/google/monitoring/metrics/MetricPoint.java
// @AutoValue
// public abstract class MetricPoint<V> implements Comparable<MetricPoint<V>> {
// 
//   /**
//    * Returns a new {@link MetricPoint} representing a value at a specific {@link Instant}.
//    *
//    * <p>Callers should insure that the count of {@code labelValues} matches the count of labels for
//    * the given metric.
//    */
//   @VisibleForTesting
//   public static <V> MetricPoint<V> create(
//       Metric<V> metric, ImmutableList<String> labelValues, Instant timestamp, V value) {
//     MetricsUtils.checkLabelValuesLength(metric, labelValues);
// 
//     return new AutoValue_MetricPoint<>(
//         metric, labelValues, Range.openClosed(timestamp, timestamp), value);
//   }
// 
//   /**
//    * Returns a new {@link MetricPoint} representing a value over an {@link Range} from {@code
//    * startTime} to {@code endTime}.
//    *
//    * <p>Callers should insure that the count of {@code labelValues} matches the count of labels for
//    * the given metric.
//    */
//   @VisibleForTesting
//   public static <V> MetricPoint<V> create(
//       Metric<V> metric,
//       ImmutableList<String> labelValues,
//       Instant startTime,
//       Instant endTime,
//       V value) {
//     MetricsUtils.checkLabelValuesLength(metric, labelValues);
// 
//     return new AutoValue_MetricPoint<>(
//         metric, labelValues, Range.openClosed(startTime, endTime), value);
//   }
// 
//   public abstract Metric<V> metric();
// 
//   public abstract ImmutableList<String> labelValues();
// 
//   public abstract Range<Instant> interval();
// 
//   public abstract V value();
// 
//   @Override
//   public int compareTo(MetricPoint<V> other) {
//     int minLength = Math.min(this.labelValues().size(), other.labelValues().size());
//     for (int index = 0; index < minLength; index++) {
//       int comparisonResult =
//           this.labelValues().get(index).compareTo(other.labelValues().get(index));
//       if (comparisonResult != 0) {
//         return comparisonResult;
//       }
//     }
//     return Integer.compare(this.labelValues().size(), other.labelValues().size());
//   }
// }


// Path: contrib/src/main/java/com/google/monitoring/metrics/contrib/AbstractMetricSubject.java
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
import com.google.monitoring.metrics.Metric;
import com.google.monitoring.metrics.MetricPoint;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nullable;

// Copyright 2017 Google LLC. 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.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License 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.google.monitoring.metrics.contrib;



/**
 * Base truth subject for asserting things about {@link Metric} instances.
 *
 * <p>For use with the Google <a href="https://google.github.io/truth/">Truth</a> framework.
 */
abstract class AbstractMetricSubject<T, S extends AbstractMetricSubject<T, S>>
    extends Subject<S, Metric<T>> {

  /** And chainer to allow fluent assertions. */
  public static class And<S extends AbstractMetricSubject<?, S>> {

    private final S subject;

    And(S subject) {
      this.subject = subject;
    }

    public S and() {
      return subject;
    }
  }

  @SuppressWarnings("unchecked")
  And<S> andChainer() {
    return new And<>((S) this);
  }

  /**
   * List of label value tuples about which an assertion has been made so far.
   *
   * <p>Used to track what tuples have been seen, in order to support hasNoOtherValues() assertions.
   */
  protected final Set<ImmutableList<String>> expectedNondefaultLabelTuples = new HashSet<>();

  /**
   * Function to convert a metric point to a nice string representation for use in error messages.
   */
  protected final Function<MetricPoint<T>, String> metricPointConverter =