private IndexType getIndexTypeFromString ( String indexTypeAsString ) { IndexType indexType ; try { indexType = IndexType . findByValue ( new Integer ( indexTypeAsString ) ) ; } catch ( NumberFormatException e ) { try { // if this is not an integer lets try to get IndexType by name indexType = IndexType . valueOf ( indexTypeAsString ) ; } catch ( IllegalArgumentException ie ) { throw new RuntimeException ( "IndexType '" + indexTypeAsString + "' is unsupported." , ie ) ; } } if ( indexType == null ) { throw new RuntimeException ( "IndexType '" + indexTypeAsString + "' is unsupported." ) ; } return indexType ; }
Getting IndexType object from indexType string