private State getState ( final Class < ? extends State > stateClass ) throws NotAvailableException { if ( ! stateMap . containsKey ( stateClass ) ) { try { final State state ; try { state = stateClass . getConstructor ( ) . newInstance ( ) ; } catch ( IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex ) { throw new CouldNotPerformException ( "Could not create instance of " + stateClass . getName ( ) , ex ) ; } stateMap . put ( stateClass , state ) ; return state ; } catch ( CouldNotPerformException ex ) { throw new NotAvailableException ( stateClass , ex ) ; } } return stateMap . get ( stateClass ) ; }
Method loads the state referred by the state class .