code: @SuppressWarnings("unchecked")
      // Justification : producer generic type is checked manually at runtime
      private OnDemandStatsProducer<S> safeCastProducer(IStatsProducer producer) throws ClassCastException {
  
          OnDemandStatsProducer onDemandStatsTypedProducer =
                  (OnDemandStatsProducer)producer;
  
          // Checking is generic type of producer is corresponds to generic type of mapper
          // By retrieving producer default stats and checking it type
          if(!(statsClass.isInstance(onDemandStatsTypedProducer.getDefaultStats())))
              throw new ClassCastException(
                      "Producer do not have generic type of " +
                              statsClass.getCanonicalName() + " required by mapper"
              );
  
          return onDemandStatsTypedProducer;
  
      }
docs: Casts producer of raw type from producers repository
  to {@link OnDemandStatsProducer} with producer stats class
  check.
  
  @param producer producer to be casted
  @return casted producer
  @throws ClassCastException if producer is not instance of {@link OnDemandStatsProducer}
  or generic type of producer stats is not same as type of mapper