@Test public void throwsWhenCreatingControllerWithNonPositiveArguments() { assertThatThrownBy(() -> TopNMetricPublicationController.create(0)) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("maxPermittedRank must be positive"); assertThatThrownBy(() -> TopNMetricPublicationController.create(-29359)) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("maxPermittedRank must be positive"); }
@SuppressWarnings("unchecked") public static <T extends Comparable> TopNMetricPublicationController<T> create(int maxPermittedRank) { Preconditions.checkState(maxPermittedRank > 0, "maxPermittedRank must be positive", SafeArg.of("maxPermittedRank", maxPermittedRank)); return new TopNMetricPublicationController<T>(Comparator.naturalOrder(), maxPermittedRank, REFRESH_INTERVAL); }
TopNMetricPublicationController { @SuppressWarnings("unchecked") public static <T extends Comparable> TopNMetricPublicationController<T> create(int maxPermittedRank) { Preconditions.checkState(maxPermittedRank > 0, "maxPermittedRank must be positive", SafeArg.of("maxPermittedRank", maxPermittedRank)); return new TopNMetricPublicationController<T>(Comparator.naturalOrder(), maxPermittedRank, REFRESH_INTERVAL); } }
TopNMetricPublicationController { @SuppressWarnings("unchecked") public static <T extends Comparable> TopNMetricPublicationController<T> create(int maxPermittedRank) { Preconditions.checkState(maxPermittedRank > 0, "maxPermittedRank must be positive", SafeArg.of("maxPermittedRank", maxPermittedRank)); return new TopNMetricPublicationController<T>(Comparator.naturalOrder(), maxPermittedRank, REFRESH_INTERVAL); } @VisibleForTesting  TopNMetricPublicationController(
            Comparator<T> comparator,
            int maxPermittedRank,
            Duration refreshInterval); }
TopNMetricPublicationController { @SuppressWarnings("unchecked") public static <T extends Comparable> TopNMetricPublicationController<T> create(int maxPermittedRank) { Preconditions.checkState(maxPermittedRank > 0, "maxPermittedRank must be positive", SafeArg.of("maxPermittedRank", maxPermittedRank)); return new TopNMetricPublicationController<T>(Comparator.naturalOrder(), maxPermittedRank, REFRESH_INTERVAL); } @VisibleForTesting  TopNMetricPublicationController(
            Comparator<T> comparator,
            int maxPermittedRank,
            Duration refreshInterval); @SuppressWarnings("unchecked") // Guaranteed correct static TopNMetricPublicationController<T> create(int maxPermittedRank); MetricPublicationFilter registerAndCreateFilter(Gauge<T> gauge); }
TopNMetricPublicationController { @SuppressWarnings("unchecked") public static <T extends Comparable> TopNMetricPublicationController<T> create(int maxPermittedRank) { Preconditions.checkState(maxPermittedRank > 0, "maxPermittedRank must be positive", SafeArg.of("maxPermittedRank", maxPermittedRank)); return new TopNMetricPublicationController<T>(Comparator.naturalOrder(), maxPermittedRank, REFRESH_INTERVAL); } @VisibleForTesting  TopNMetricPublicationController(
            Comparator<T> comparator,
            int maxPermittedRank,
            Duration refreshInterval); @SuppressWarnings("unchecked") // Guaranteed correct static TopNMetricPublicationController<T> create(int maxPermittedRank); MetricPublicationFilter registerAndCreateFilter(Gauge<T> gauge);  }