Java 类org.springframework.boot.actuate.metrics.util.SimpleInMemoryRepository.Callback 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InMemoryMetricRepository.java   
@Override
public void increment(Delta<?> delta) {
    final String metricName = delta.getName();
    final int amount = delta.getValue().intValue();
    final Date timestamp = delta.getTimestamp();
    this.metrics.update(metricName, new Callback<Metric<?>>() {
        @Override
        public Metric<?> modify(Metric<?> current) {
            if (current != null) {
                Metric<? extends Number> metric = current;
                return new Metric<Long>(metricName,
                        metric.increment(amount).getValue(), timestamp);
            }
            else {
                return new Metric<Long>(metricName, Long.valueOf(amount), timestamp);
            }
        }
    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InMemoryRichGaugeRepository.java   
@Override
public void set(Metric<?> metric) {

    final String name = metric.getName();
    final double value = metric.getValue().doubleValue();
    this.repository.update(name, new Callback<RichGauge>() {
        @Override
        public RichGauge modify(RichGauge current) {
            if (current == null) {
                current = new RichGauge(name, value);
            }
            else {
                current.set(value);
            }
            return current;
        }
    });

}
项目:spring-boot-concourse    文件:InMemoryMetricRepository.java   
@Override
public void increment(Delta<?> delta) {
    final String metricName = delta.getName();
    final int amount = delta.getValue().intValue();
    final Date timestamp = delta.getTimestamp();
    this.metrics.update(metricName, new Callback<Metric<?>>() {
        @Override
        public Metric<?> modify(Metric<?> current) {
            if (current != null) {
                Metric<? extends Number> metric = current;
                return new Metric<Long>(metricName,
                        metric.increment(amount).getValue(), timestamp);
            }
            else {
                return new Metric<Long>(metricName, Long.valueOf(amount), timestamp);
            }
        }
    });
}
项目:spring-boot-concourse    文件:InMemoryRichGaugeRepository.java   
@Override
public void set(Metric<?> metric) {

    final String name = metric.getName();
    final double value = metric.getValue().doubleValue();
    this.repository.update(name, new Callback<RichGauge>() {
        @Override
        public RichGauge modify(RichGauge current) {
            if (current == null) {
                current = new RichGauge(name, value);
            }
            else {
                current.set(value);
            }
            return current;
        }
    });

}
项目:contestparser    文件:InMemoryMetricRepository.java   
@Override
public void increment(Delta<?> delta) {
    final String metricName = delta.getName();
    final int amount = delta.getValue().intValue();
    final Date timestamp = delta.getTimestamp();
    this.metrics.update(metricName, new Callback<Metric<?>>() {
        @Override
        public Metric<?> modify(Metric<?> current) {
            if (current != null) {
                Metric<? extends Number> metric = current;
                return new Metric<Long>(metricName,
                        metric.increment(amount).getValue(), timestamp);
            }
            else {
                return new Metric<Long>(metricName, new Long(amount), timestamp);
            }
        }
    });
}
项目:contestparser    文件:InMemoryRichGaugeRepository.java   
@Override
public void set(Metric<?> metric) {

    final String name = metric.getName();
    final double value = metric.getValue().doubleValue();
    this.repository.update(name, new Callback<RichGauge>() {
        @Override
        public RichGauge modify(RichGauge current) {
            if (current == null) {
                current = new RichGauge(name, value);
            }
            else {
                current.set(value);
            }
            return current;
        }
    });

}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SimpleInMemoryRepositoryTests.java   
@Test
public void updateExisting() {
    this.repository.set("foo", "spam");
    this.repository.update("foo", new Callback<String>() {
        @Override
        public String modify(String current) {
            return "bar";
        }
    });
    assertThat(this.repository.findOne("foo")).isEqualTo("bar");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SimpleInMemoryRepositoryTests.java   
@Test
public void updateNonexistent() {
    this.repository.update("foo", new Callback<String>() {
        @Override
        public String modify(String current) {
            return "bar";
        }
    });
    assertThat(this.repository.findOne("foo")).isEqualTo("bar");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SimpleInMemoryRepositoryTests.java   
@Override
public Boolean call() throws Exception {
    this.repository.update("foo", new Callback<Integer>() {

        @Override
        public Integer modify(Integer current) {
            if (current == null) {
                return RepositoryUpdate.this.delta;
            }
            return current + RepositoryUpdate.this.delta;
        }

    });
    return true;
}
项目:spring-boot-concourse    文件:SimpleInMemoryRepositoryTests.java   
@Test
public void updateExisting() {
    this.repository.set("foo", "spam");
    this.repository.update("foo", new Callback<String>() {
        @Override
        public String modify(String current) {
            return "bar";
        }
    });
    assertThat(this.repository.findOne("foo")).isEqualTo("bar");
}
项目:spring-boot-concourse    文件:SimpleInMemoryRepositoryTests.java   
@Test
public void updateNonexistent() {
    this.repository.update("foo", new Callback<String>() {
        @Override
        public String modify(String current) {
            return "bar";
        }
    });
    assertThat(this.repository.findOne("foo")).isEqualTo("bar");
}
项目:spring-boot-concourse    文件:SimpleInMemoryRepositoryTests.java   
@Override
public Boolean call() throws Exception {
    this.repository.update("foo", new Callback<Integer>() {

        @Override
        public Integer modify(Integer current) {
            if (current == null) {
                return RepositoryUpdate.this.delta;
            }
            return current + RepositoryUpdate.this.delta;
        }

    });
    return true;
}
项目:contestparser    文件:InMemoryRepositoryTests.java   
@Test
public void updateExisting() {
    this.repository.set("foo", "spam");
    this.repository.update("foo", new Callback<String>() {
        @Override
        public String modify(String current) {
            return "bar";
        }
    });
    assertEquals("bar", this.repository.findOne("foo"));
}
项目:contestparser    文件:InMemoryRepositoryTests.java   
@Test
public void updateNonexistent() {
    this.repository.update("foo", new Callback<String>() {
        @Override
        public String modify(String current) {
            return "bar";
        }
    });
    assertEquals("bar", this.repository.findOne("foo"));
}