1 | package com.framsticks.framclipse.script.model; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.Collections; |
---|
5 | import java.util.List; |
---|
6 | |
---|
7 | import com.thoughtworks.xstream.annotations.XStreamAlias; |
---|
8 | import com.thoughtworks.xstream.annotations.XStreamAsAttribute; |
---|
9 | |
---|
10 | public class Element { |
---|
11 | |
---|
12 | @XStreamAsAttribute |
---|
13 | private String name, type; |
---|
14 | |
---|
15 | @XStreamAsAttribute |
---|
16 | private boolean function; |
---|
17 | |
---|
18 | @XStreamAsAttribute |
---|
19 | private Double min, max; |
---|
20 | |
---|
21 | @XStreamAlias("default") |
---|
22 | @XStreamAsAttribute |
---|
23 | private Double def; |
---|
24 | |
---|
25 | private String description; |
---|
26 | |
---|
27 | private List<Argument> arguments = new ArrayList<Argument>(0); |
---|
28 | |
---|
29 | public String getName() { |
---|
30 | return name; |
---|
31 | } |
---|
32 | |
---|
33 | public String getType() { |
---|
34 | return type; |
---|
35 | } |
---|
36 | |
---|
37 | public boolean isFunction() { |
---|
38 | return function; |
---|
39 | } |
---|
40 | |
---|
41 | public Double getMin() { |
---|
42 | return min; |
---|
43 | } |
---|
44 | |
---|
45 | public Double getMax() { |
---|
46 | return max; |
---|
47 | } |
---|
48 | |
---|
49 | public Double getDef() { |
---|
50 | return def; |
---|
51 | } |
---|
52 | |
---|
53 | public String getDescription() { |
---|
54 | return description; |
---|
55 | } |
---|
56 | |
---|
57 | public List<Argument> getArguments() { |
---|
58 | return arguments != null ? arguments : Collections.<Argument> emptyList(); |
---|
59 | } |
---|
60 | |
---|
61 | public String toString() { |
---|
62 | return name + " : " + type; |
---|
63 | }; |
---|
64 | |
---|
65 | public String argumentsString(boolean includeType) { |
---|
66 | StringBuilder builder = new StringBuilder("("); |
---|
67 | if (!getArguments().isEmpty()) { |
---|
68 | for (int i = 0; i < getArguments().size(); i++) { |
---|
69 | Argument a = arguments.get(i); |
---|
70 | if (includeType) { |
---|
71 | builder.append(a.getType() + " "); |
---|
72 | } |
---|
73 | builder.append(a.getName(i) + ", "); |
---|
74 | } |
---|
75 | builder.delete(builder.length() - 2, builder.length()); |
---|
76 | } |
---|
77 | return builder.append(")").toString(); |
---|
78 | } |
---|
79 | |
---|
80 | public String returnType() { |
---|
81 | return type != null ? type : "?"; |
---|
82 | } |
---|
83 | |
---|
84 | } |
---|