I have a tricky situation here, which I would like to optimize from the code perspective. Is there any way to shorten the following method via Lambda / Java8 expressions?
// total amount of audiences
registry.register("metric.persons.total", new CachedGauge<Integer>(1,TimeUnit.MINUTES) {
@Override
protected Integer loadValue() {
return personService.findAll().size();
}
});
The CachedGauge class is looking like this:
public abstract class CachedGauge<T> implements Gauge<T> {
protected CachedGauge(long timeout, TimeUnit timeoutUnit) {
...
}
protected abstract T loadValue();
...
}
}
Would be really great to see if there is a way, the tricky part here is that there is a default constructor and the class is parameterized.
best, fri
personServicecome from the anonymous class's containing scope, or is it a public/protected field inherited fromCachedGauge?