/**
  * Injects any parameters configured via the given {@code ClassBridge} annotation into the given
  * object, in case this is a {@link ParameterizedBridge}.
  *
  * @param classBridgeConfiguration the parameter source
  * @param classBridge the object to inject the parameters into
  */
 public void injectParameters(ClassBridge classBridgeConfiguration, Object classBridge) {
   if (classBridgeConfiguration.params().length > 0
       && ParameterizedBridge.class.isAssignableFrom(classBridge.getClass())) {
     Map<String, String> params =
         new HashMap<String, String>(classBridgeConfiguration.params().length);
     for (Parameter param : classBridgeConfiguration.params()) {
       params.put(param.name(), param.value());
     }
     ((ParameterizedBridge) classBridge).setParameterValues(params);
   }
 }
  /**
   * This extracts and instantiates the implementation class from a {@code ClassBridge} annotation.
   *
   * @param cb the class bridge annotation
   * @param clazz the {@code Class} on which the annotation is defined on
   * @return Returns the specified {@code FieldBridge} instance
   */
  public FieldBridge extractType(ClassBridge cb, Class<?> clazz) {
    FieldBridge bridge = null;
    Class<?> bridgeType = null;

    if (cb != null) {
      bridgeType = cb.impl();
      if (bridgeType != null) {
        try {
          Object instance = bridgeType.newInstance();
          if (FieldBridge.class.isAssignableFrom(bridgeType)) {
            bridge = (FieldBridge) instance;
          } else if (org.hibernate.search.bridge.TwoWayStringBridge.class.isAssignableFrom(
              bridgeType)) {
            bridge =
                new TwoWayString2FieldBridgeAdaptor(
                    (org.hibernate.search.bridge.TwoWayStringBridge) instance);
          } else if (org.hibernate.search.bridge.StringBridge.class.isAssignableFrom(bridgeType)) {
            bridge =
                new String2FieldBridgeAdaptor((org.hibernate.search.bridge.StringBridge) instance);
          } else {
            throw LOG.noFieldBridgeInterfaceImplementedByClassBridge(bridgeType.getName());
          }
        } catch (Exception e) {
          throw LOG.cannotInstantiateClassBridgeOfType(bridgeType.getName(), clazz.getName(), e);
        }
      }
    }
    if (bridge == null) {
      throw LOG.unableToDetermineClassBridge(ClassBridge.class.getName());
    }

    populateReturnType(clazz, bridgeType, bridge);

    return bridge;
  }