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

org.unlaxer.tinyexpression.loader.FormulaInfoAdditionalFields Maven / Gradle / Ivy

The newest version!
package org.unlaxer.tinyexpression.loader;

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Optional;
import java.util.function.Function;

import org.unlaxer.tinyexpression.loader.model.FormulaInfo;

public class FormulaInfoAdditionalFields{
  
  private final String multiTenancyAttributeName;
  private final LinkedHashSet additionalAttributeNames;
  private final Function nameExtractor;

  public FormulaInfoAdditionalFields(String multiTenancyAttributeName,Function nameExtractor) {
    super();
    this.multiTenancyAttributeName = multiTenancyAttributeName;
    additionalAttributeNames = new LinkedHashSet<>();
    this.nameExtractor = nameExtractor;
  }
  
  public Collection additionalAttributeNames(){
    return additionalAttributeNames;
  }
  
  public void addAttributeName(String attributeName) {
    additionalAttributeNames.add(attributeName);
  }
  
  public void addAttributeName(Collection attributeNames) {
    additionalAttributeNames.addAll(attributeNames);
  }
  
  public Optional multiTenancyAttributeName(){
    return Optional.ofNullable(multiTenancyAttributeName);
  }
  
  /**
   * 
   * @param formulaInfo
   * @return
   */
  public String getName(FormulaInfo formulaInfo) {
    
//    String checkKind = formulaInfo.extraValueByKey.get("checkKind");
//    return checkKind != null ? checkKind : formulaInfo.calculatorName;
    return nameExtractor.apply(formulaInfo);
  }
//  public String formulaNameAttributeName() {
//    return formulaNameAttributeName;
//  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy