code: public static void setClassConf(Configuration  conf,
                                    String         configKey,
                                    Class<?>       clazz) {
      String existingClass = conf.get(configKey);
      String className = clazz.getName();
  
      if (existingClass != null && !existingClass.equals(className)) {
          throw new RuntimeException(
              "Already registered a different thriftClass for "
              + configKey
              + ". old: " + existingClass
              + " new: " + className);
      } else {
        conf.set(configKey, className);
      }
    }
docs: A helper to set configuration to class name.
  Throws a RuntimeExcpetion if the
  configuration is already set to a different class name.