@ SuppressWarnings ( "unchecked" ) private Setup createSetup ( Media media ) { final Configurer configurer = new Configurer ( media ) ; try { final FeaturableConfig config = FeaturableConfig . imports ( configurer ) ; final String setup = config . getSetupName ( ) ; final Class < ? extends Setup > setupClass ; if ( setup . isEmpty ( ) ) { final Class < ? > clazz = classLoader . loadClass ( config . getClassName ( ) ) ; final Constructor < ? > constructor = UtilReflection . getCompatibleConstructorParent ( clazz , new Class < ? > [ ] { Services . class , Setup . class } ) ; setupClass = ( Class < ? extends Setup > ) constructor . getParameterTypes ( ) [ SETUP_INDEX ] ; } else { setupClass = ( Class < ? extends Setup > ) classLoader . loadClass ( config . getSetupName ( ) ) ; } return UtilReflection . create ( setupClass , new Class < ? > [ ] { Media . class } , media ) ; } catch ( final ClassNotFoundException exception ) { throw new LionEngineException ( exception , ERROR_SETUP_CLASS ) ; } catch ( final NoSuchMethodException exception ) { throw new LionEngineException ( exception , ERROR_CONSTRUCTOR_MISSING + media . getPath ( ) ) ; } }
Create a setup from its media .