1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.databind.codegen.impl;
7   
8   import com.squareup.javapoet.ClassName;
9   
10  import gov.nist.secauto.metaschema.core.model.IModelDefinition;
11  import gov.nist.secauto.metaschema.core.model.IModule;
12  import gov.nist.secauto.metaschema.core.util.CollectionUtil;
13  import gov.nist.secauto.metaschema.core.util.ObjectUtils;
14  import gov.nist.secauto.metaschema.databind.codegen.IGeneratedDefinitionClass;
15  import gov.nist.secauto.metaschema.databind.codegen.IGeneratedModuleClass;
16  
17  import java.nio.file.Path;
18  import java.util.Collection;
19  import java.util.Map;
20  
21  import edu.umd.cs.findbugs.annotations.NonNull;
22  
23  public class DefaultGeneratedModuleClass
24      extends DefaultGeneratedClass
25      implements IGeneratedModuleClass {
26    @NonNull
27    private final IModule module;
28    @NonNull
29    private final Map<IModelDefinition, IGeneratedDefinitionClass> definitionClassMap;
30    @NonNull
31    private final String packageName;
32  
33    public DefaultGeneratedModuleClass(
34        @NonNull IModule module,
35        @NonNull ClassName className,
36        @NonNull Path classFile,
37        @NonNull Map<IModelDefinition, IGeneratedDefinitionClass> definitionClassMap,
38        @NonNull String packageName) {
39      super(classFile, className);
40      this.module = module;
41      this.definitionClassMap = CollectionUtil.unmodifiableMap(definitionClassMap);
42      this.packageName = packageName;
43    }
44  
45    @Override
46    public IModule getModule() {
47      return module;
48    }
49  
50    @Override
51    public Collection<IGeneratedDefinitionClass> getGeneratedDefinitionClasses() {
52      return ObjectUtils.notNull(definitionClassMap.values());
53    }
54  
55    @Override
56    public String getPackageName() {
57      return packageName;
58    }
59  }