void changeTypeContext(ResolutionContext old, ResolutionContext new_, MethodDeclaration m) {
   m.setType(changeTypeContext(old, new_, m.getType()));
   m.setBody(
       new BlockStmt(
           Collections.singletonList(
               new ThrowStmt(
                   new ObjectCreationExpr(
                       null,
                       new ClassOrInterfaceType("UnsupportedOperationException"),
                       Collections.emptyList())))));
   NodeUtil.forChildren(
       m,
       node -> {
         Expression scope = node.getScope();
         // TODO: Currently guesses that it's a type name if first character is uppercase.
         // Should check for fields/variables which match instead
         if (scope instanceof NameExpr
             && Character.isUpperCase(((NameExpr) scope).getName().charAt(0))) {
           String name = ((NameExpr) scope).getName();
           node.setScope(ASTHelper.createNameExpr(new_.typeToString(old.resolve(name))));
         }
       },
       MethodCallExpr.class);
   NodeUtil.forChildren(
       m,
       node -> node.setType(changeTypeContext(old, new_, node.getType())),
       VariableDeclarationExpr.class);
   NodeUtil.forChildren(
       m, node -> node.setType(changeTypeContext(old, new_, node.getType())), TypeExpr.class);
   NodeUtil.forChildren(
       m,
       node -> node.setType(changeTypeContext(old, new_, node.getType())),
       com.github.javaparser.ast.body.Parameter.class);
 }
  @Override
  public Boolean visit(final MethodDeclaration n1, final Node arg) {
    final MethodDeclaration n2 = (MethodDeclaration) arg;

    // javadoc are checked at CompilationUnit

    if (n1.getModifiers() != n2.getModifiers()) {
      return Boolean.FALSE;
    }

    if (n1.getArrayCount() != n2.getArrayCount()) {
      return Boolean.FALSE;
    }

    if (!objEquals(n1.getName(), n2.getName())) {
      return Boolean.FALSE;
    }

    if (!nodeEquals(n1.getType(), n2.getType())) {
      return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
      return Boolean.FALSE;
    }

    if (!nodeEquals(n1.getBody(), n2.getBody())) {
      return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getParameters(), n2.getParameters())) {
      return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getThrows(), n2.getThrows())) {
      return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) {
      return Boolean.FALSE;
    }
    if (n1.isDefault() != n2.isDefault()) {
      return Boolean.FALSE;
    }
    return Boolean.TRUE;
  }
  private JavaMethod createMethod(MethodDeclaration method) {
    String className = classStack.peek().getName();
    String name = method.getName();
    boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC);
    String returnType = method.getType().toString();
    ArrayList<Argument> arguments = new ArrayList<Argument>();

    if (method.getParameters() != null) {
      for (Parameter parameter : method.getParameters()) {
        arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName()));
      }
    }

    return new JavaMethod(
        className,
        name,
        isStatic,
        returnType,
        null,
        arguments,
        method.getBeginLine(),
        method.getEndLine());
  }
 @Override
 public void setReturnType(Type type) {
   declaration.setType(setType(type, declaration.getType()));
 }
 @Override
 public Type getReturnType() {
   return getContext().resolve(declaration.getType());
 }