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.databind.codegen.typeinfo.IMetaschemaClassFactory;
9   
10  import java.io.IOException;
11  import java.net.URI;
12  import java.nio.file.Path;
13  
14  import edu.umd.cs.findbugs.annotations.NonNull;
15  import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16  
17  class PackageProductionImpl implements IPackageProduction {
18    @NonNull
19    private final URI xmlNamespace;
20    @NonNull
21    private final IGeneratedClass packageInfoClass;
22  
23    @SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Use of final fields")
24    public PackageProductionImpl(
25        @NonNull PackageMetadata metadata,
26        @NonNull IMetaschemaClassFactory classFactory,
27        @NonNull Path targetDirectory)
28        throws IOException {
29      this.xmlNamespace = metadata.getXmlNamespace();
30      this.packageInfoClass = classFactory.generatePackageInfoClass(
31          metadata.getPackageName(),
32          this.xmlNamespace,
33          metadata.getModuleProductions(),
34          targetDirectory);
35    }
36  
37    @Override
38    public URI getXmlNamespace() {
39      return xmlNamespace;
40    }
41  
42    /**
43     * Get the generated package-info class associated with this package.
44     *
45     * @return the package-info class
46     */
47    @Override
48    public IGeneratedClass getGeneratedClass() {
49      return packageInfoClass;
50    }
51  }