1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.synchronoss.cpo.meta.domain;
22
23 import org.slf4j.*;
24 import org.synchronoss.cpo.meta.bean.CpoFunctionBean;
25
26 import java.util.*;
27
28 public class CpoFunction extends CpoFunctionBean {
29
30 private static final long serialVersionUID = 1L;
31
32 private static final Logger logger = LoggerFactory.getLogger(CpoFunction.class);
33 List<CpoArgument> arguments = new ArrayList<>();
34
35 public CpoFunction() {
36 }
37
38 public List<CpoArgument> getArguments() {
39 return arguments;
40 }
41
42 public void addArgument(CpoArgument argument) {
43 if (argument != null) {
44 arguments.add(argument);
45 }
46 }
47
48 public boolean removeArgument(CpoArgument argument) {
49 if (argument != null) {
50 return arguments.remove(argument);
51 }
52 return false;
53 }
54
55 public boolean removeArgument(int index) {
56 if (index > 0 && index < arguments.size()) {
57 return (arguments.remove(index) != null);
58 }
59 return false;
60 }
61
62
63
64
65
66
67
68 public String parameterToString(CpoFunction function) {
69 List<CpoArgument> args;
70 int j;
71 CpoArgument argument;
72 CpoAttribute attribute;
73 int type = 0;
74 Class<?> c;
75 StringBuilder sb = new StringBuilder("Parameter list for ");
76
77 if (function == null) {
78 return " null function.";
79 }
80
81
82
83 args = function.getArguments();
84
85 for (j = 1; j <= args.size(); j++) {
86 argument = args.get(j - 1);
87
88 if (argument != null) {
89 try {
90 attribute = argument.getAttribute();
91 c = attribute.getGetter().getReturnType();
92
93
94 if (c != null) {
95 sb.append(" col" + j + ":" + c.getName() + " type:"
96 + type + " ");
97 } else {
98 sb.append(j + ":null type:" + type + " ");
99 }
100 } catch (Exception e) {
101 String msg = "parameterToString() Failed:";
102 logger.error(msg);
103 }
104 }
105 }
106
107 return sb.toString();
108 }
109
110 @Override
111 public String toString() {
112 return this.getName();
113 }
114
115 public String toStringFull() {
116 return super.toString();
117 }
118 }