/** * Create a new instance. * * @param registry * Registry to use. * @param id * Identifier for the metric being registered. * @return * Counter instance. */ public static IntervalCounter get(Registry registry, Id id) { ConcurrentMap<Id, Object> state = registry.state(); Object c = Utils.computeIfAbsent(state, id, i -> new IntervalCounter(registry, i)); if (!(c instanceof IntervalCounter)) { Utils.propagateTypeError(registry, id, IntervalCounter.class, c.getClass()); c = new IntervalCounter(new NoopRegistry(), id); } return (IntervalCounter) c; }
/** * Create a new instance. * * @param registry * Registry to use. * @param id * Identifier for the metric being registered. * @return * Counter instance. */ public static IntervalCounter get(Registry registry, Id id) { ConcurrentMap<Id, Object> state = registry.state(); Object c = Utils.computeIfAbsent(state, id, i -> new IntervalCounter(registry, i)); if (!(c instanceof IntervalCounter)) { Utils.propagateTypeError(registry, id, IntervalCounter.class, c.getClass()); c = new IntervalCounter(new NoopRegistry(), id); } return (IntervalCounter) c; }