1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package dev.metaschema.databind.codegen.typeinfo;
7
8 import com.squareup.javapoet.TypeName;
9
10 import dev.metaschema.databind.codegen.typeinfo.def.IDefinitionTypeInfo;
11 import edu.umd.cs.findbugs.annotations.NonNull;
12
13 /**
14 * Provides type information for a Java property generated from a Metaschema
15 * construct.
16 * <p>
17 * This interface defines methods for retrieving names and types used when
18 * generating Java code for Metaschema elements.
19 */
20 public interface ITypeInfo {
21 /**
22 * Get the parent definition type info that contains this type.
23 *
24 * @return the parent type info
25 */
26 @NonNull
27 IDefinitionTypeInfo getParentTypeInfo();
28
29 /**
30 * Get the name to use for the property. If the property is a collection type,
31 * then this will be the group-as name, else this will be the use name or the
32 * name if the use name is not set.
33 *
34 * @return the name
35 */
36 @NonNull
37 String getBaseName();
38
39 /**
40 * The name to use for Java constructs that refer to the item. This is used for
41 * when a field is collection-based and there is a need to refer to a single
42 * item, such as in an add/remove method name.
43 *
44 * @return the item base name
45 */
46 @NonNull
47 default String getItemBaseName() {
48 return getBaseName();
49 }
50
51 /**
52 * Get the Java property name for the property.
53 *
54 * @return the Java property name
55 */
56 @NonNull
57 String getPropertyName();
58
59 /**
60 * Gets the name of the Java field for this property.
61 *
62 * @return the Java field name
63 */
64 @NonNull
65 String getJavaFieldName();
66
67 /**
68 * Gets the type of the associated Java field for the property.
69 *
70 * @return the Java type for the field
71 */
72 @NonNull
73 TypeName getJavaFieldType();
74
75 /**
76 * Gets the type of the property's item.
77 *
78 * @return the Java type for the item
79 */
80 @NonNull
81 default TypeName getJavaItemType() {
82 return getJavaFieldType();
83 }
84 }