@ SuppressWarnings ( "unchecked" ) public < TEntity > DocumentConventions registerIdConvention ( Class < TEntity > clazz , BiFunction < String , TEntity , String > function ) { assertNotFrozen ( ) ; _listOfRegisteredIdConventions . stream ( ) . filter ( x -> x . first . equals ( clazz ) ) . findFirst ( ) . ifPresent ( x -> _listOfRegisteredIdConventions . remove ( x ) ) ; int index ; for ( index = 0 ; index < _listOfRegisteredIdConventions . size ( ) ; index ++ ) { Tuple < Class , BiFunction < String , Object , String > > entry = _listOfRegisteredIdConventions . get ( index ) ; if ( entry . first . isAssignableFrom ( clazz ) ) { break ; } } _listOfRegisteredIdConventions . add ( index , Tuple . create ( clazz , ( BiFunction < String , Object , String > ) function ) ) ; return this ; }
Register an id convention for a single type ( and all of its derived types . Note that you can still fall back to the DocumentIdGenerator if you want .