public IStorageProvider build ( ) { if ( appInfoRepo == null ) { throw new IllegalStateException ( "Undefined application information repository" ) ; } if ( userCredentialsRepo == null ) { throw new IllegalStateException ( "Undefined user credentials repository" ) ; } try { Constructor providerConstructor = providerClass . getConstructor ( StorageBuilder . class ) ; StorageProvider providerInstance = ( StorageProvider ) providerConstructor . newInstance ( this ) ; return providerInstance ; } catch ( InvocationTargetException itex ) { Throwable cause = itex . getCause ( ) ; if ( cause instanceof RuntimeException ) { throw ( RuntimeException ) cause ; } // should not happen, providers constructors do not throw checked exceptions: throw new UnsupportedOperationException ( "Error instantiating the provider " + providerClass . getSimpleName ( ) , itex ) ; } catch ( Exception ex ) { throw new UnsupportedOperationException ( "Error instantiating the provider " + providerClass . getSimpleName ( ) , ex ) ; } }
Builds a provider - specific storage implementation by passing this builder in constructor . Each implementation gets its required information from builder .