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

org.unlaxer.tinyexpression.evaluator.javacode.MethodInvocationBuilder Maven / Gradle / Ivy

There is a newer version: 1.4.4
Show newest version
package org.unlaxer.tinyexpression.evaluator.javacode;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.unlaxer.Token;
import org.unlaxer.tinyexpression.parser.ArgumentsParser;
import org.unlaxer.tinyexpression.parser.MethodInvocationParser;

public class MethodInvocationBuilder implements TokenCodeBuilder{
  
  public static final MethodInvocationBuilder SINGLETON = new MethodInvocationBuilder();

  @Override
  public void build(SimpleJavaCodeBuilder builder, Token token, 
      TinyExpressionTokens tinyExpressionTokens) {
    
    String methodNameAsString = MethodInvocationParser.getMethodNameAsString(token);
    Optional parametersClause = MethodInvocationParser.getParametersClause(token);
    List parameterTokens =
        parametersClause.isEmpty() ? 
        Collections.emptyList():
        ArgumentsParser.parameterTokens(methodNameAsString, parametersClause.get(), tinyExpressionTokens);
    
    builder
      .append(methodNameAsString)
      .append("(calculateContext");
    
    if(false == parameterTokens.isEmpty()) {
      builder
        .append(",");
    }
    ParametersBuilder.buildParameter(builder, parameterTokens, tinyExpressionTokens);
    builder
      .append(")");
     return ;
  }
  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy