import {Behavior, TextFormatter} from "@webbpm/base-package";
import {ErvuReplaceValueModel} from "./model/ErvuReplaceValueModel";

export class ReplaceValueTextFormatter extends Behavior implements TextFormatter {
  public replaceModels: ErvuReplaceValueModel[]

  format(value: string): string {
    if (this.replaceModels) {
      for (let i = 0; i < this.replaceModels.length; i++) {
        let model = this.replaceModels[i];
        if (value == model.valueToReplace) {
          return model.value ? model.value : '';
        }
      }
    }

    return value;
  }
}
