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

tech.jhipster.lite.module.domain.replacement.TextReplacer Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package tech.jhipster.lite.module.domain.replacement;

import java.util.function.BiFunction;
import tech.jhipster.lite.shared.error.domain.Assert;

public record TextReplacer(ReplacementCondition condition, String text) implements ElementReplacer {
  public TextReplacer {
    Assert.notNull("condition", condition);
    Assert.notBlank("text", text);
  }

  @Override
  public boolean notMatchIn(String content) {
    return !content.contains(text());
  }

  @Override
  public BiFunction replacement() {
    return (content, replacement) -> content.replace(text(), replacement);
  }

  @Override
  public String searchMatcher() {
    return text();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy