1 /* 2 * Portions of this software was developed by employees of the National Institute 3 * of Standards and Technology (NIST), an agency of the Federal Government and is 4 * being made available as a public service. Pursuant to title 17 United States 5 * Code Section 105, works of NIST employees are not subject to copyright 6 * protection in the United States. This software may be subject to foreign 7 * copyright. Permission in the United States and in foreign countries, to the 8 * extent that NIST may hold copyright, to use, copy, modify, create derivative 9 * works, and distribute this software and its documentation without fee is hereby 10 * granted on a non-exclusive basis, provided that this notice and disclaimer 11 * of warranty appears in all copies. 12 * 13 * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER 14 * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY 15 * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM 17 * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE 18 * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT 19 * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, 20 * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, 21 * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, 22 * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR 23 * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT 24 * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. 25 */ 26 27 package gov.nist.secauto.metaschema.databind.codegen.typeinfo; 28 29 import com.squareup.javapoet.ClassName; 30 31 import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition; 32 import gov.nist.secauto.metaschema.core.model.IFieldDefinition; 33 import gov.nist.secauto.metaschema.core.model.IFlagContainer; 34 import gov.nist.secauto.metaschema.core.model.IModule; 35 import gov.nist.secauto.metaschema.databind.codegen.config.IBindingConfiguration; 36 37 import edu.umd.cs.findbugs.annotations.NonNull; 38 import edu.umd.cs.findbugs.annotations.Nullable; 39 40 public interface ITypeResolver { 41 /** 42 * Construct a new type resolver using the default implementation. 43 * 44 * @param bindingConfiguration 45 * the binding configuration used to configure types 46 * @return the type resolver 47 */ 48 @NonNull 49 static ITypeResolver newTypeResolver(@NonNull IBindingConfiguration bindingConfiguration) { 50 return new DefaultTypeResolver(bindingConfiguration); 51 } 52 53 /** 54 * Get type information for the provided {@code definition}. 55 * 56 * @param definition 57 * the definition to get type information for 58 * @return the type information 59 */ 60 @NonNull 61 IAssemblyDefinitionTypeInfo getTypeInfo(@NonNull IAssemblyDefinition definition); 62 63 /** 64 * Get type information for the provided {@code definition}. 65 * 66 * @param definition 67 * the definition to get type information for 68 * @return the type information 69 */ 70 @NonNull 71 IFieldDefinitionTypeInfo getTypeInfo(@NonNull IFieldDefinition definition); 72 73 /** 74 * Get type information for the provided {@code definition}. 75 * 76 * @param definition 77 * the definition to get type information for 78 * @return the type information 79 */ 80 @NonNull 81 IModelDefinitionTypeInfo getTypeInfo(@NonNull IFlagContainer definition); 82 83 /** 84 * Get the name of the class associated with the provided Module module. 85 * 86 * @param module 87 * the Module module that will be built as a class 88 * @return the class name information for the Module module 89 */ 90 @NonNull 91 ClassName getClassName(@NonNull IModule module); 92 93 /** 94 * Get the name of the class associated with the provided definition. 95 * 96 * @param definition 97 * a definition that may be built as a subclass 98 * @return the class name information for the definition 99 */ 100 @NonNull 101 ClassName getClassName(@NonNull IFlagContainer definition); 102 103 /** 104 * Get the name of the base class to use for the class associated with the 105 * provided definition. 106 * 107 * @param definition 108 * a definition that may be built as a class 109 * @return the name of the base class or {@code null} if no base class is to be 110 * used 111 */ 112 @Nullable 113 ClassName getBaseClassName(@NonNull IFlagContainer definition); 114 115 /** 116 * Get the Java package name to use for the provided Module module. 117 * 118 * @param module 119 * the Module module 120 * @return the Java package name 121 */ 122 @NonNull 123 String getPackageName(@NonNull IModule module); 124 }