implementation/src/main/java/io/smallrye/metrics/MetricsRegistryImpl.java
private MetricType inferMetricType(Class<?> clazz) {
        MetricType direct = metricTypeFromClass(clazz);
        if (direct != null) {
            return direct;
        } else {
            MetricType candidateType = null;
            // recursively scan the superclass first, then implemented interfaces
            Class<?> superClass = clazz.getSuperclass();
            if (superClass != null && !superClass.equals(Object.class)) {
                candidateType = inferMetricType(superClass);
            }
            for (Class<?> implementedInterface : clazz.getInterfaces()) {
                MetricType newCandidateType = inferMetricType(implementedInterface);
                if (candidateType == null) {
                    candidateType = newCandidateType;
                } else {
                    if (newCandidateType != null && !candidateType.equals(newCandidateType)) {
                        throw SmallRyeMetricsMessages.msg.ambiguousMetricType(newCandidateType, candidateType);
                    }
                }
            }
            return candidateType;
        }
    }
/**
     * Guess the metric type from a class object. Recursively scans its
     * superclasses and implemented interfaces.
     * If no metric type can be inferred, returns null.
     * If multiple metric types are inferred, throws an IllegalArgumentException.
     */
Guess the metric type from a class object. Recursively scans its
superclasses and implemented interfaces.
If no metric type can be inferred, returns null.
If multiple metric types are inferred, throws an IllegalArgumentException.
Guess the metric type from a class object . Recursively scans its superclasses and implemented interfaces . If no metric type can be inferred returns null . If multiple metric types are inferred throws an IllegalArgumentException .
private MetricType inferMetricType(Class<?> clazz) {
        MetricType direct = metricTypeFromClass(clazz);
        if (direct != null) {
            return direct;
        } else {
            MetricType candidateType = null;
            Class<?> superClass = clazz.getSuperclass();
            if (superClass != null && !superClass.equals(Object.class)) {
                candidateType = inferMetricType(superClass);
            }
            for (Class<?> implementedInterface : clazz.getInterfaces()) {
                MetricType newCandidateType = inferMetricType(implementedInterface);
                if (candidateType == null) {
                    candidateType = newCandidateType;
                } else {
                    if (newCandidateType != null && !candidateType.equals(newCandidateType)) {
                        throw SmallRyeMetricsMessages.msg.ambiguousMetricType(newCandidateType, candidateType);
                    }
                }
            }
            return candidateType;
        }
    }
private MetricType inferMetricType ( Class < ? > clazz ) { MetricType direct = metricTypeFromClass ( clazz ) ; if ( direct != null ) { return direct ; } else { MetricType candidateType = null ; Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null && ! superClass . equals ( Object . class ) ) { candidateType = inferMetricType ( superClass ) ; } for ( Class < ? > implementedInterface : clazz . getInterfaces ( ) ) { MetricType newCandidateType = inferMetricType ( implementedInterface ) ; if ( candidateType == null ) { candidateType = newCandidateType ; } else { if ( newCandidateType != null && ! candidateType . equals ( newCandidateType ) ) { throw SmallRyeMetricsMessages . msg . ambiguousMetricType ( newCandidateType , candidateType ) ; } } } return candidateType ; } }
Guess the metric type from a class object.
Guess the metric type from a class object .
// recursively scan the superclass first, then implemented interfaces