Package javarag.impl.inst

Source Code of javarag.impl.inst.SynthesizedAttributeHandler

package javarag.impl.inst;

import javarag.MissingDefinitionException;

public class SynthesizedAttributeHandler implements AttributeHandler {
  private final String name;
  private final ClassMap<MethodInvoker> methods;

  public SynthesizedAttributeHandler(String name, ClassMap<MethodInvoker> methods) {
    this.name = name;
    this.methods = methods;
  }

  @Override
  public String getName() {
    return name;
  }

  @Override
  public Object evaluate(Context context, Request request) {
    MethodInvoker invoker = methods.get(request.getNode().getClass());
    if (invoker == null) {
      throw new MissingDefinitionException(request);
    }
    Object[] args = Arrays.prependArray(request.getNode(), request.getArguments());
    return invoker.invoke(args);
  }

}
TOP

Related Classes of javarag.impl.inst.SynthesizedAttributeHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.