Update groupId to org.onap.ccsdk.sli
[ccsdk/sli/core.git] / sli / common / src / main / java / org / onap / ccsdk / sli / core / sli / SvcLogicFunctionCall.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : CCSDK
4  * ================================================================================
5  * Copyright (C) 2017 ONAP
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.ccsdk.sli.core.sli;
22
23 public class SvcLogicFunctionCall extends SvcLogicExpression {
24         
25         private String functionName;
26         
27         public SvcLogicFunctionCall(String functionName)
28         {
29                 this.functionName = functionName;
30         }
31
32         public String getFunctionName() {
33                 return functionName;
34         }
35
36         public void setFunctionName(String functionName) {
37                 this.functionName = functionName;
38         }
39         
40         public String toString()
41         {
42                 StringBuffer sbuff = new StringBuffer();
43                 
44                 sbuff.append(functionName);
45                 sbuff.append("(");
46                 boolean needComma = false;
47                 for (SvcLogicExpression operand: getOperands())
48                 {
49                         if (needComma)
50                         {
51                                 sbuff.append(",");
52                         }
53                         else
54                         {
55                                 needComma = true;
56                         }
57                         sbuff.append(operand.toString());
58                         
59                 }
60                 sbuff.append(")");
61                 return(sbuff.toString());
62         }
63         
64         public String asParsedExpr()
65         {
66                 StringBuffer sbuff = new StringBuffer();
67                 
68                 sbuff.append("(");
69                 sbuff.append(functionName);
70                 for (SvcLogicExpression operand: getOperands())
71                 {
72                         sbuff.append(" ");
73                         sbuff.append(operand.asParsedExpr());
74                 }
75                 sbuff.append(")");
76                 return(sbuff.toString());
77         }
78
79 }