1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.databind.codegen;
7   
8   import gov.nist.secauto.metaschema.core.model.IModule;
9   import gov.nist.secauto.metaschema.core.util.ObjectUtils;
10  import gov.nist.secauto.metaschema.databind.model.IBoundModule;
11  
12  import java.util.Collection;
13  
14  import edu.umd.cs.findbugs.annotations.NonNull;
15  
16  /**
17   * Provides information about a generated Java class that represents a Module
18   * module.
19   */
20  public interface IGeneratedModuleClass extends IGeneratedClass {
21  
22    /**
23     * Get the associated Module module data.
24     *
25     * @return the module data
26     */
27    @NonNull
28    IModule getModule();
29  
30    /**
31     * Get the Java package name associated with the Module module.
32     *
33     * @return the package name
34     */
35    @NonNull
36    String getPackageName();
37  
38    /**
39     * Get the collection of generated classes representing definitions associated
40     * with the Module module.
41     *
42     * @return the collection of definition classes
43     */
44    @NonNull
45    Collection<IGeneratedDefinitionClass> getGeneratedDefinitionClasses();
46  
47    /**
48     * Dynamicly load this class.
49     *
50     * @param classLoader
51     *          the class loader to use to load this class
52     * @return the module class
53     * @throws ClassNotFoundException
54     *           if this classwas not found
55     * @since 2.0.0
56     */
57    @SuppressWarnings("unchecked")
58    @NonNull
59    default Class<? extends IBoundModule> load(@NonNull ClassLoader classLoader) throws ClassNotFoundException {
60      return ObjectUtils.notNull((Class<? extends IBoundModule>) classLoader.loadClass(getClassName().reflectionName()));
61    }
62  }