6
6
7
7
import java .util .Collection ;
8
8
import java .util .HashMap ;
9
- import java .util .Iterator ;
10
9
import java .util .Map ;
11
10
12
11
import org .hibernate .models .internal .BasicModelBuildingContextImpl ;
13
12
import org .hibernate .models .internal .ModelsLogging ;
14
13
import org .hibernate .models .internal .SimpleClassLoading ;
15
14
16
15
/**
17
- * Bootstrapping
16
+ * Bootstrapping of {@linkplain SourceModelBuildingContext}
18
17
*
19
18
* @author Steve Ebersole
20
19
*/
@@ -29,38 +28,87 @@ public class ModelsConfiguration {
29
28
public ModelsConfiguration () {
30
29
}
31
30
31
+ /**
32
+ * Configuration values in effect.
33
+ *
34
+ * @apiNote Configuration settings only have effect with certain
35
+ * providers.
36
+ */
32
37
public Map <Object , Object > getConfigValues () {
33
38
return configValues ;
34
39
}
35
40
36
- public Object configValue (Object key , Object value ) {
41
+ /**
42
+ * Provide a {@linkplain #getConfigValues() configuration value}.
43
+ */
44
+ public ModelsConfiguration configValue (Object key , Object value ) {
45
+ setConfigValue ( key , value );
46
+ return this ;
47
+ }
48
+
49
+ /**
50
+ * Provide a {@linkplain #getConfigValues() configuration value}.
51
+ */
52
+ public Object setConfigValue (Object key , Object value ) {
37
53
return configValues .put ( key , value );
38
54
}
39
55
56
+ /**
57
+ * {@linkplain ClassLoading} to use.
58
+ */
40
59
public ClassLoading getClassLoading () {
41
60
return classLoading ;
42
61
}
43
62
44
- public void setClassLoading (ClassLoading classLoading ) {
63
+ /**
64
+ * Specify a specific {@linkplain #getClassLoading() ClassLoading} to use.
65
+ */
66
+ public ModelsConfiguration setClassLoading (ClassLoading classLoading ) {
45
67
this .classLoading = classLoading ;
68
+ return this ;
46
69
}
47
70
71
+ /**
72
+ * A primer for {@linkplain ClassDetailsRegistry} and
73
+ * {@linkplain AnnotationDescriptorRegistry} applied when
74
+ * the {@linkplain SourceModelBuildingContext} is first built.
75
+ */
48
76
public RegistryPrimer getRegistryPrimer () {
49
77
return registryPrimer ;
50
78
}
51
79
52
- public void setRegistryPrimer (RegistryPrimer registryPrimer ) {
80
+ /**
81
+ * Specify a {@linkplain #getRegistryPrimer() registry primer}.
82
+ */
83
+ public ModelsConfiguration setRegistryPrimer (RegistryPrimer registryPrimer ) {
53
84
this .registryPrimer = registryPrimer ;
85
+ return this ;
54
86
}
55
87
88
+ /**
89
+ * An {@linkplain SourceModelBuildingContextProvider explicit provider} to use.
90
+ *
91
+ * @see #setExplicitContextProvider
92
+ */
56
93
public SourceModelBuildingContextProvider getExplicitContextProvider () {
57
94
return explicitContextProvider ;
58
95
}
59
96
60
- public void setExplicitContextProvider (SourceModelBuildingContextProvider explicitContextProvider ) {
97
+ /**
98
+ * Specify an {@linkplain #getExplicitContextProvider explicit provider} for
99
+ * {@linkplain SourceModelBuildingContext} instances.
100
+ *
101
+ * @implNote Prefer use of Java {@linkplain java.util.ServiceLoader service loading}
102
+ * for supplying a specific provider.
103
+ */
104
+ public ModelsConfiguration setExplicitContextProvider (SourceModelBuildingContextProvider explicitContextProvider ) {
61
105
this .explicitContextProvider = explicitContextProvider ;
106
+ return this ;
62
107
}
63
108
109
+ /**
110
+ * Build the {@linkplain SourceModelBuildingContext} instance.
111
+ */
64
112
public SourceModelBuildingContext bootstrap () {
65
113
if ( explicitContextProvider != null ) {
66
114
final SourceModelBuildingContext context = explicitContextProvider .produceContext (
@@ -78,9 +126,7 @@ public SourceModelBuildingContext bootstrap() {
78
126
if ( discoveredProviders .size () > 1 ) {
79
127
ModelsLogging .MODELS_LOGGER .debugf ( "Multiple SourceModelBuildingContextProvider impls found" );
80
128
}
81
- final Iterator <SourceModelBuildingContextProvider > iterator = discoveredProviders .iterator ();
82
- while ( iterator .hasNext () ) {
83
- final SourceModelBuildingContextProvider provider = iterator .next ();
129
+ for ( SourceModelBuildingContextProvider provider : discoveredProviders ) {
84
130
final SourceModelBuildingContext context = provider .produceContext (
85
131
classLoading ,
86
132
registryPrimer ,
0 commit comments