1 /*
2 * Themis: Java Project Framework
3 * Copyright 2012-2026. Tony Washer
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17 package io.github.tonywasher.joceanus.themis.parser.node;
18
19 import com.github.javaparser.ast.body.Parameter;
20 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
21 import io.github.tonywasher.joceanus.themis.parser.base.ThemisModifierList;
22 import io.github.tonywasher.joceanus.themis.parser.base.ThemisParserDef;
23
24 import java.util.List;
25
26 /**
27 * Class Declaration.
28 */
29 public class ThemisNodeParameter
30 extends ThemisBaseNode<Parameter> {
31 /**
32 * The name.
33 */
34 private final ThemisNodeInstance theName;
35
36 /**
37 * The type.
38 */
39 private final ThemisTypeInstance theType;
40
41 /**
42 * The modifiers.
43 */
44 private final ThemisModifierList theModifiers;
45
46 /**
47 * The annotations.
48 */
49 private final List<ThemisExpressionInstance> theAnnotations;
50
51 /**
52 * Constructor.
53 *
54 * @param pParser the parser
55 * @param pParameter the parameter
56 * @throws OceanusException on error
57 */
58 ThemisNodeParameter(final ThemisParserDef pParser,
59 final Parameter pParameter) throws OceanusException {
60 super(pParser, pParameter);
61 theModifiers = pParser.parseModifierList(pParameter.getModifiers());
62 theName = pParser.parseNode(pParameter.getName());
63 theType = pParser.parseType(pParameter.getType());
64 theAnnotations = pParser.parseExprList(pParameter.getAnnotations());
65 }
66
67 /**
68 * Obtain the name.
69 *
70 * @return the name
71 */
72 public ThemisNodeInstance getName() {
73 return theName;
74 }
75
76 /**
77 * Obtain the type.
78 *
79 * @return the type
80 */
81 public ThemisTypeInstance getType() {
82 return theType;
83 }
84
85 /**
86 * Obtain the modifiers.
87 *
88 * @return the modifiers
89 */
90 public ThemisModifierList getModifiers() {
91 return theModifiers;
92 }
93
94 /**
95 * Obtain the annotations.
96 *
97 * @return the annotations
98 */
99 public List<ThemisExpressionInstance> getAnnotations() {
100 return theAnnotations;
101 }
102
103 /**
104 * Is the parameter varArgs?
105 *
106 * @return true/false
107 */
108 public boolean isVarArgs() {
109 return getNode().isVarArgs();
110 }
111 }