All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.devonfw.tools.ide.migrator.line.RegexLineMigration Maven / Gradle / Ivy

Go to download

Code for configurator the creates or updates configuration of IDEs (Eclipse, etc.).

There is a newer version: 3.0.0-beta25
Show newest version
package com.devonfw.tools.ide.migrator.line;

import java.io.FileFilter;
import java.util.regex.Pattern;

/**
 * Implementation of {@link LineMigration} based on regex {@link Pattern} replacement.
 */
public class RegexLineMigration extends AbstractLineMigration {

  private final Pattern regex;

  private final String replacement;

  /**
   * The constructor.
   *
   * @param regex the {@link Pattern} to match.
   * @param replacement the replacement.
   * @param fileFilter the {@link FileFilter} to accept the files that shall be migrated.
   */
  public RegexLineMigration(Pattern regex, String replacement, FileFilter fileFilter) {

    super(fileFilter);
    this.regex = regex;
    this.replacement = replacement;
  }

  @Override
  protected String migrate(String line) {

    return this.regex.matcher(line).replaceAll(this.replacement);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy