001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package dev.metaschema.databind.codegen;
007
008import java.util.Collection;
009
010import dev.metaschema.core.model.IModule;
011import dev.metaschema.core.util.ObjectUtils;
012import dev.metaschema.databind.model.IBoundModule;
013import edu.umd.cs.findbugs.annotations.NonNull;
014
015/**
016 * Provides information about a generated Java class that represents a Module
017 * module.
018 */
019public interface IGeneratedModuleClass extends IGeneratedClass {
020
021  /**
022   * Get the associated Module module data.
023   *
024   * @return the module data
025   */
026  @NonNull
027  IModule getModule();
028
029  /**
030   * Get the Java package name associated with the Module module.
031   *
032   * @return the package name
033   */
034  @NonNull
035  String getPackageName();
036
037  /**
038   * Get the collection of generated classes representing definitions associated
039   * with the Module module.
040   *
041   * @return the collection of definition classes
042   */
043  @NonNull
044  Collection<IGeneratedDefinitionClass> getGeneratedDefinitionClasses();
045
046  /**
047   * Dynamicly load this class.
048   *
049   * @param classLoader
050   *          the class loader to use to load this class
051   * @return the module class
052   * @throws ClassNotFoundException
053   *           if this classwas not found
054   * @since 2.0.0
055   */
056  @SuppressWarnings("unchecked")
057  @NonNull
058  default Class<? extends IBoundModule> load(@NonNull ClassLoader classLoader) throws ClassNotFoundException {
059    return ObjectUtils.notNull((Class<? extends IBoundModule>) classLoader.loadClass(getClassName().reflectionName()));
060  }
061}