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.VariableDeclarator;
20 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
21 import io.github.tonywasher.joceanus.themis.parser.base.ThemisParserDef;
22
23 /**
24 * Class Declaration.
25 */
26 public class ThemisNodeVariable
27 extends ThemisBaseNode<VariableDeclarator> {
28 /**
29 * The name.
30 */
31 private final ThemisNodeInstance theName;
32
33 /**
34 * The type.
35 */
36 private final ThemisTypeInstance theType;
37
38 /**
39 * The initializer.
40 */
41 private final ThemisExpressionInstance theInitializer;
42
43 /**
44 * Constructor.
45 *
46 * @param pParser the parser
47 * @param pDeclaration the declaration
48 * @throws OceanusException on error
49 */
50 ThemisNodeVariable(final ThemisParserDef pParser,
51 final VariableDeclarator pDeclaration) throws OceanusException {
52 super(pParser, pDeclaration);
53 theName = pParser.parseNode(pDeclaration.getName());
54 theType = pParser.parseType(pDeclaration.getType());
55 theInitializer = pParser.parseExpression(pDeclaration.getInitializer().orElse(null));
56 }
57
58 /**
59 * Obtain the name.
60 *
61 * @return the name
62 */
63 public ThemisNodeInstance getName() {
64 return theName;
65 }
66
67 /**
68 * Obtain the type.
69 *
70 * @return the type
71 */
72 public ThemisTypeInstance getType() {
73 return theType;
74 }
75
76 /**
77 * Obtain the initializer.
78 *
79 * @return the initializer
80 */
81 public ThemisExpressionInstance getInitializer() {
82 return theInitializer;
83 }
84 }