Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,11 @@ public R getSingleResult() {

protected static <T> T uniqueElement(List<T> list) throws NonUniqueResultException {
final int size = list.size();
if ( size == 0 ) {
return null;
}
else {
final T first = list.get( 0 );
// todo (6.0) : add a setting here to control whether to perform this validation or not
for ( int i = 1; i < size; i++ ) {
if ( list.get( i ) != first ) {
throw new NonUniqueResultException( list.size() );
}
}
return first;
}
return switch ( size ) {
case 0 -> null;
case 1 -> list.get( 0 );
default -> throw new NonUniqueResultException( size );
};
}

@Override
Expand Down
Loading