1 /* 2 * Copyright (C) 2007-2010 Jlio Vilmar Gesser. 3 * Copyright (C) 2011, 2013-2016 The JavaParser Team. 4 * 5 * This file is part of JavaParser. 6 * 7 * JavaParser can be used either under the terms of 8 * a) the GNU Lesser General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * b) the terms of the Apache License 12 * 13 * You should have received a copy of both licenses in LICENCE.LGPL and 14 * LICENCE.APACHE. Please refer to those files for details. 15 * 16 * JavaParser is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 */ 21 22 package com.github.javaparser.ast.expr; 23 24 import com.github.javaparser.Range; 25 import com.github.javaparser.ast.body.Parameter; 26 import com.github.javaparser.ast.stmt.Statement; 27 import com.github.javaparser.ast.visitor.GenericVisitor; 28 import com.github.javaparser.ast.visitor.VoidVisitor; 29 30 import java.util.List; 31 32 import static com.github.javaparser.utils.Utils.*; 33 34 /** 35 * Lambda expression. 36 * 37 * @author Raquel Pau 38 */ 39 public class LambdaExpr extends Expression { 40 41 private List<Parameter> parameters; 42 43 private boolean parametersEnclosed; 44 45 private Statement body; 46 47 public LambdaExpr() { 48 } 49 50 public LambdaExpr(Range range, List<Parameter> parameters, Statement body, 51 boolean parametersEnclosed) { 52 53 super(range); 54 setParameters(parameters); 55 setBody(body); 56 setParametersEnclosed(parametersEnclosed); 57 } 58 59 public List<Parameter> getParameters() { 60 parameters = ensureNotNull(parameters); 61 return parameters; 62 } 63 64 public LambdaExpr setParameters(List<Parameter> parameters) { 65 this.parameters = parameters; 66 setAsParentNodeOf(this.parameters); 67 return this; 68 } 69 70 public Statement getBody() { 71 return body; 72 } 73 74 public LambdaExpr setBody(Statement body) { 75 this.body = body; 76 setAsParentNodeOf(this.body); 77 return this; 78 } 79 80 @Override 81 public <R, A> R accept(GenericVisitor<R, A> v, A arg) { 82 return v.visit(this, arg); 83 } 84 85 @Override 86 public <A> void accept(VoidVisitor<A> v, A arg) { 87 v.visit(this, arg); 88 } 89 90 public boolean isParametersEnclosed() { 91 return parametersEnclosed; 92 } 93 94 public LambdaExpr setParametersEnclosed(boolean parametersEnclosed) { 95 this.parametersEnclosed = parametersEnclosed; 96 return this; 97 } 98 99 } 100