1
2
3
4
5
6 package dev.metaschema.databind.model;
7
8 import java.lang.reflect.Constructor;
9 import java.lang.reflect.InvocationTargetException;
10 import java.net.URI;
11 import java.util.Collection;
12 import java.util.List;
13
14 import dev.metaschema.core.model.IModuleExtended;
15 import dev.metaschema.core.util.ObjectUtils;
16 import dev.metaschema.databind.IBindingContext;
17 import edu.umd.cs.findbugs.annotations.NonNull;
18
19
20
21
22
23 public interface IBoundModule
24 extends IModuleExtended<
25 IBoundModule,
26 IBoundDefinitionModelComplex,
27 IBoundDefinitionFlag,
28 IBoundDefinitionModelField<?>,
29 IBoundDefinitionModelAssembly> {
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 @NonNull
45 static IBoundModule newInstance(
46 @NonNull Class<? extends IBoundModule> clazz,
47 @NonNull IBindingContext bindingContext,
48 @NonNull List<? extends IBoundModule> importedModules) {
49
50 Constructor<? extends IBoundModule> constructor;
51 try {
52 constructor = clazz.getDeclaredConstructor(List.class, IBindingContext.class);
53 } catch (NoSuchMethodException ex) {
54 throw new IllegalArgumentException(ex);
55 }
56
57 try {
58 return ObjectUtils.notNull(constructor.newInstance(importedModules, bindingContext));
59 } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) {
60 throw new IllegalArgumentException(ex);
61 }
62 }
63
64
65
66
67
68
69 @NonNull
70 IBindingContext getBindingContext();
71
72 @Override
73 default URI getLocation() {
74
75 return null;
76 }
77
78 @Override
79 Collection<IBoundDefinitionModelAssembly> getAssemblyDefinitions();
80
81 @Override
82 IBoundDefinitionModelAssembly getAssemblyDefinitionByName(@NonNull Integer name);
83
84 @Override
85 Collection<IBoundDefinitionModelField<?>> getFieldDefinitions();
86
87 @Override
88 IBoundDefinitionModelField<?> getFieldDefinitionByName(@NonNull Integer name);
89 }