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.lethe.analysis;
18
19 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
20 import io.github.tonywasher.joceanus.themis.lethe.analysis.ThemisAnalysisDataMap.ThemisAnalysisDataType;
21 import io.github.tonywasher.joceanus.themis.lethe.analysis.ThemisAnalysisGeneric.ThemisAnalysisGenericBase;
22 import io.github.tonywasher.joceanus.themis.lethe.analysis.ThemisAnalysisGeneric.ThemisAnalysisGenericRef;
23
24 /**
25 * Reference structure.
26 */
27 public class ThemisAnalysisReference {
28 /**
29 * The generic.
30 */
31 private ThemisAnalysisGeneric theGeneric;
32
33 /**
34 * The array.
35 */
36 private final ThemisAnalysisArray theArray;
37
38 /**
39 * The dataType.
40 */
41 private ThemisAnalysisDataType theDataType;
42
43 /**
44 * Constructor.
45 *
46 * @param pDataType the dataType
47 * @param pGeneric the generic
48 * @param pArray the array
49 */
50 ThemisAnalysisReference(final ThemisAnalysisDataType pDataType,
51 final ThemisAnalysisGeneric pGeneric,
52 final ThemisAnalysisArray pArray) {
53 /* Store parameters */
54 theDataType = pDataType;
55 theGeneric = pGeneric;
56 theArray = pArray;
57 }
58
59 /**
60 * Obtain the dataType.
61 *
62 * @return the dataType
63 */
64 ThemisAnalysisDataType getDataType() {
65 return theDataType;
66 }
67
68 /**
69 * Resolve the generic reference.
70 *
71 * @param pParser the parser
72 * @throws OceanusException on error
73 */
74 void resolveGeneric(final ThemisAnalysisParser pParser) throws OceanusException {
75 /* Resolve any generic base instance */
76 if (theGeneric instanceof ThemisAnalysisGenericBase myBase) {
77 theGeneric = new ThemisAnalysisGenericRef(pParser, myBase);
78 }
79 }
80
81 /**
82 * Update the dataType.
83 *
84 * @param pType the updated type
85 */
86 void updateDataType(final ThemisAnalysisDataType pType) {
87 theDataType = pType;
88 }
89
90 @Override
91 public String toString() {
92 String myName = theDataType.toString();
93 if (theGeneric != null) {
94 myName += theGeneric.toString();
95 }
96 if (theArray != null) {
97 myName += theArray.toString();
98 }
99 return myName;
100 }
101 }