public static String generateIndexName ( final BsonDocument index ) { StringBuilder indexName = new StringBuilder ( ) ; for ( final String keyNames : index . keySet ( ) ) { if ( indexName . length ( ) != 0 ) { indexName . append ( ' ' ) ; } indexName . append ( keyNames ) . append ( ' ' ) ; BsonValue ascOrDescValue = index . get ( keyNames ) ; if ( ascOrDescValue instanceof BsonNumber ) { indexName . append ( ( ( BsonNumber ) ascOrDescValue ) . intValue ( ) ) ; } else if ( ascOrDescValue instanceof BsonString ) { indexName . append ( ( ( BsonString ) ascOrDescValue ) . getValue ( ) . replace ( ' ' , ' ' ) ) ; } } return indexName . toString ( ) ; }
Convenience method to generate an index name from the set of fields it is over .