@SuppressWarnings("unchecked")
  @Override
  public void init(NamedList args) {

    Object patternParam = args.remove(PATTERN_PARAM);

    if (patternParam == null) {
      throw new SolrException(
          ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PATTERN_PARAM);
    }

    try {
      pattern = Pattern.compile(patternParam.toString());
    } catch (PatternSyntaxException e) {
      throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid regex: " + patternParam, e);
    }

    Object replacementParam = args.remove(REPLACEMENT_PARAM);
    if (replacementParam == null) {
      throw new SolrException(
          ErrorCode.SERVER_ERROR, "Missing required init parameter: " + REPLACEMENT_PARAM);
    }

    Boolean literalReplacement = args.removeBooleanArg(LITERAL_REPLACEMENT_PARAM);

    if (literalReplacement != null) {
      literalReplacementEnabled = literalReplacement;
    }

    if (literalReplacementEnabled) {
      replacement = Matcher.quoteReplacement(replacementParam.toString());
    } else {
      replacement = replacementParam.toString();
    }

    super.init(args);
  }
 /** macro */
 private static SelectorParams parseSelectorParams(NamedList args) {
   return FieldMutatingUpdateProcessorFactory.parseSelectorParams(args);
 }
  @SuppressWarnings("unchecked")
  @Override
  public void init(NamedList args) {
    Object d = args.remove(DEST_PARAM);
    if (null == d) {
      throw new SolrException(SERVER_ERROR, "Init param '" + DEST_PARAM + "' must be specified");
    } else if (!(d instanceof CharSequence)) {
      throw new SolrException(
          SERVER_ERROR, "Init param '" + DEST_PARAM + "' must be a string (ie: 'str')");
    }
    dest = d.toString();

    List<Object> sources = args.getAll(SOURCE_PARAM);
    if (0 == sources.size()) {
      throw new SolrException(SERVER_ERROR, "Init param '" + SOURCE_PARAM + "' must be specified");
    }
    if (1 == sources.size() && sources.get(0) instanceof NamedList) {
      // nested set of selector options
      NamedList selectorConfig = (NamedList) args.remove(SOURCE_PARAM);

      srcInclusions = parseSelectorParams(selectorConfig);

      List<Object> excList = selectorConfig.getAll("exclude");

      for (Object excObj : excList) {
        if (null == excObj) {
          throw new SolrException(
              SERVER_ERROR, "Init param '" + SOURCE_PARAM + "' child 'exclude' can not be null");
        }
        if (!(excObj instanceof NamedList)) {
          throw new SolrException(
              SERVER_ERROR, "Init param '" + SOURCE_PARAM + "' child 'exclude' must be <lst/>");
        }
        NamedList exc = (NamedList) excObj;
        srcExclusions.add(parseSelectorParams(exc));
        if (0 < exc.size()) {
          throw new SolrException(
              SERVER_ERROR,
              "Init param '"
                  + SOURCE_PARAM
                  + "' has unexpected 'exclude' sub-param(s): '"
                  + selectorConfig.getName(0)
                  + "'");
        }
        // call once per instance
        selectorConfig.remove("exclude");
      }

      if (0 < selectorConfig.size()) {
        throw new SolrException(
            SERVER_ERROR,
            "Init param '"
                + SOURCE_PARAM
                + "' contains unexpected child param(s): '"
                + selectorConfig.getName(0)
                + "'");
      }
    } else {
      // source better be one or more strings
      srcInclusions.fieldName =
          new HashSet<String>(FieldMutatingUpdateProcessorFactory.oneOrMany(args, "source"));
    }

    if (0 < args.size()) {
      throw new SolrException(SERVER_ERROR, "Unexpected init param(s): '" + args.getName(0) + "'");
    }

    super.init(args);
  }
 @SuppressWarnings("unchecked")
 @Override
 public void init(NamedList args) {
   // no length specific init args
   super.init(args);
 }