source: java/main/src/main/java/com/framsticks/params/types/ProcedureParam.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1package com.framsticks.params.types;
2
3import com.framsticks.params.Param;
4import com.framsticks.params.ParamBuilder;
5import com.framsticks.params.ValueParam;
6
7import java.util.List;
8
9import javax.annotation.Nullable;
10import javax.annotation.concurrent.Immutable;
11
12/**
13 * @author Piotr Sniegowski
14 */
15@Immutable
16public class ProcedureParam extends Param {
17        private final ValueParam resultType;
18        private final List<ValueParam> argumentsType;
19        private final String signatureString;
20
21        /**
22         * @param builder
23         */
24        public ProcedureParam(ParamBuilder builder) {
25                super(builder);
26                resultType = builder.getResultType();
27                argumentsType = builder.getArgumentsType();
28                assert argumentsType != null;
29
30                StringBuilder b = new StringBuilder().append("p");
31
32                if (resultType != null) {
33                        b.append(" ").append(resultType.getFramsTypeName());
34                }
35                b.append("(");
36                boolean first = true;
37                for (ValueParam arg : argumentsType) {
38                        if (first) {
39                                first = false;
40                        } else {
41                                b.append(", ");
42                        }
43
44                        b.append(arg.getFramsTypeName());
45                        if (arg.getName() != null) {
46                                b.append(" ").append(arg.getName());
47                        }
48                }
49                b.append(")");
50
51                signatureString = b.toString();
52        }
53
54        public @Nullable ValueParam getResultType() {
55                return resultType;
56        }
57
58        public List<ValueParam> getArgumentsType() {
59                return argumentsType;
60        }
61
62        @Override
63        public String getFramsTypeName() {
64                return signatureString;
65        }
66
67}
Note: See TracBrowser for help on using the repository browser.