@ SuppressWarnings ( "unchecked" ) protected < T extends Meter > T getOrCreate ( Id id , Class < T > cls , T dflt , Function < Id , T > factory ) { try { Preconditions . checkNotNull ( id , "id" ) ; Meter m = Utils . computeIfAbsent ( meters , id , i -> compute ( factory . apply ( i ) , dflt ) ) ; if ( ! cls . isAssignableFrom ( m . getClass ( ) ) ) { logTypeError ( id , cls , m . getClass ( ) ) ; m = dflt ; } return ( T ) m ; } catch ( Exception e ) { propagate ( e ) ; return dflt ; } }
Helper used to get or create an instance of a core meter type . This is mostly used internally to this implementation but may be useful in rare cases for creating customizations based on a core type in a sub - class .