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

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

  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;
  }
}
