66
77import java .util .Collection ;
88import java .util .HashMap ;
9- import java .util .Iterator ;
109import java .util .Map ;
1110
1211import org .hibernate .models .internal .BasicModelBuildingContextImpl ;
1312import org .hibernate .models .internal .ModelsLogging ;
1413import org .hibernate .models .internal .SimpleClassLoading ;
1514
1615/**
17- * Bootstrapping
16+ * Bootstrapping of {@linkplain SourceModelBuildingContext}
1817 *
1918 * @author Steve Ebersole
2019 */
@@ -29,38 +28,87 @@ public class ModelsConfiguration {
2928 public ModelsConfiguration () {
3029 }
3130
31+ /**
32+ * Configuration values in effect.
33+ *
34+ * @apiNote Configuration settings only have effect with certain
35+ * providers.
36+ */
3237 public Map <Object , Object > getConfigValues () {
3338 return configValues ;
3439 }
3540
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 ) {
3753 return configValues .put ( key , value );
3854 }
3955
56+ /**
57+ * {@linkplain ClassLoading} to use.
58+ */
4059 public ClassLoading getClassLoading () {
4160 return classLoading ;
4261 }
4362
44- public void setClassLoading (ClassLoading classLoading ) {
63+ /**
64+ * Specify a specific {@linkplain #getClassLoading() ClassLoading} to use.
65+ */
66+ public ModelsConfiguration setClassLoading (ClassLoading classLoading ) {
4567 this .classLoading = classLoading ;
68+ return this ;
4669 }
4770
71+ /**
72+ * A primer for {@linkplain ClassDetailsRegistry} and
73+ * {@linkplain AnnotationDescriptorRegistry} applied when
74+ * the {@linkplain SourceModelBuildingContext} is first built.
75+ */
4876 public RegistryPrimer getRegistryPrimer () {
4977 return registryPrimer ;
5078 }
5179
52- public void setRegistryPrimer (RegistryPrimer registryPrimer ) {
80+ /**
81+ * Specify a {@linkplain #getRegistryPrimer() registry primer}.
82+ */
83+ public ModelsConfiguration setRegistryPrimer (RegistryPrimer registryPrimer ) {
5384 this .registryPrimer = registryPrimer ;
85+ return this ;
5486 }
5587
88+ /**
89+ * An {@linkplain SourceModelBuildingContextProvider explicit provider} to use.
90+ *
91+ * @see #setExplicitContextProvider
92+ */
5693 public SourceModelBuildingContextProvider getExplicitContextProvider () {
5794 return explicitContextProvider ;
5895 }
5996
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 ) {
61105 this .explicitContextProvider = explicitContextProvider ;
106+ return this ;
62107 }
63108
109+ /**
110+ * Build the {@linkplain SourceModelBuildingContext} instance.
111+ */
64112 public SourceModelBuildingContext bootstrap () {
65113 if ( explicitContextProvider != null ) {
66114 final SourceModelBuildingContext context = explicitContextProvider .produceContext (
@@ -78,9 +126,7 @@ public SourceModelBuildingContext bootstrap() {
78126 if ( discoveredProviders .size () > 1 ) {
79127 ModelsLogging .MODELS_LOGGER .debugf ( "Multiple SourceModelBuildingContextProvider impls found" );
80128 }
81- final Iterator <SourceModelBuildingContextProvider > iterator = discoveredProviders .iterator ();
82- while ( iterator .hasNext () ) {
83- final SourceModelBuildingContextProvider provider = iterator .next ();
129+ for ( SourceModelBuildingContextProvider provider : discoveredProviders ) {
84130 final SourceModelBuildingContext context = provider .produceContext (
85131 classLoading ,
86132 registryPrimer ,
0 commit comments