1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.testsupport.builder;
7   
8   import java.net.URI;
9   
10  import dev.metaschema.core.model.IModule;
11  import dev.metaschema.core.model.ISource;
12  import dev.metaschema.core.util.ObjectUtils;
13  import edu.umd.cs.findbugs.annotations.NonNull;
14  import edu.umd.cs.findbugs.annotations.Nullable;
15  
16  /**
17   * A builder for creating mock {@link IModule} instances for testing purposes.
18   */
19  public interface IModuleBuilder {
20  
21    /**
22     * Create a new builder.
23     *
24     * @return the new builder
25     */
26    @NonNull
27    static IModuleBuilder builder() {
28      return new ModuleBuilder().reset();
29    }
30  
31    /**
32     * Reset the builder to its default state.
33     *
34     * @return this builder
35     */
36    @NonNull
37    IModuleBuilder reset();
38  
39    /**
40     * Set the XML namespace for the module.
41     *
42     * @param namespace
43     *          the namespace URI string
44     * @return this builder
45     */
46    @NonNull
47    IModuleBuilder namespace(@NonNull String namespace);
48  
49    /**
50     * Set the XML namespace for the module.
51     *
52     * @param namespace
53     *          the namespace URI
54     * @return this builder
55     */
56    @NonNull
57    default IModuleBuilder namespace(@NonNull URI namespace) {
58      return namespace(ObjectUtils.notNull(namespace.toASCIIString()));
59    }
60  
61    /**
62     * Set the short name for the module.
63     *
64     * @param shortName
65     *          the short name
66     * @return this builder
67     */
68    @NonNull
69    IModuleBuilder shortName(@NonNull String shortName);
70  
71    /**
72     * Set the version for the module.
73     *
74     * @param version
75     *          the version string
76     * @return this builder
77     */
78    @NonNull
79    IModuleBuilder version(@NonNull String version);
80  
81    /**
82     * Set the source information for the module.
83     *
84     * @param source
85     *          the source information
86     * @return this builder
87     */
88    @NonNull
89    IModuleBuilder source(@NonNull ISource source);
90  
91    /**
92     * Add a flag definition to the module.
93     *
94     * @param flag
95     *          the flag builder to add
96     * @return this builder
97     */
98    @NonNull
99    IModuleBuilder flag(@Nullable IFlagBuilder flag);
100 
101   /**
102    * Add a field definition to the module.
103    *
104    * @param field
105    *          the field builder to add
106    * @return this builder
107    */
108   @NonNull
109   IModuleBuilder field(@Nullable IFieldBuilder field);
110 
111   /**
112    * Add an assembly definition to the module.
113    *
114    * @param assembly
115    *          the assembly builder to add
116    * @return this builder
117    */
118   @NonNull
119   IModuleBuilder assembly(@Nullable IAssemblyBuilder assembly);
120 
121   /**
122    * Build the mock module.
123    *
124    * @return the new mock module
125    */
126   @NonNull
127   IModule toModule();
128 }