org.unlaxer.tinyexpression.loader.FormulaInfoAdditionalFields Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tinyExpression Show documentation
Show all versions of tinyExpression Show documentation
TinyExpression implemented with Unlaxer
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;
// }
}