@@ -152,46 +152,29 @@ private Document getLog(String argument) {
152152 }
153153
154154 private Document handleAdminCommand (DatabaseCommand command , Document query ) {
155- switch (command .getCommand ()) {
156- case LIST_DATABASES : {
157- return handleListDatabases ();
158- }
159- case FIND : {
160- return handleFind (command , query );
161- }
162- case REPL_SET_GET_STATUS : {
163- throw new NoReplicationEnabledException ();
164- }
165- case GET_LOG : {
155+ return switch (command .getCommand ()) {
156+ case LIST_DATABASES -> handleListDatabases ();
157+ case FIND -> handleFind (command , query );
158+ case REPL_SET_GET_STATUS -> throw new NoReplicationEnabledException ();
159+ case GET_LOG -> {
166160 final Object argument = query .get (command .getQueryValue ());
167- return getLog (argument == null ? null : argument .toString ());
168- }
169- case RENAME_COLLECTION : {
170- return handleRenameCollection (command .getQueryValue (), query );
161+ yield getLog (argument == null ? null : argument .toString ());
171162 }
172- case GET_LAST_ERROR : {
163+ case RENAME_COLLECTION -> handleRenameCollection (command .getQueryValue (), query );
164+ case GET_LAST_ERROR -> {
173165 log .debug ("getLastError on admin database" );
174- return successResponse ();
175- }
176- case CONNECTION_STATUS : {
177- return handleConnectionStatus ();
166+ yield successResponse ();
178167 }
179- case HOST_INFO : {
180- return handleHostInfo ();
181- }
182- case GET_CMD_LINE_OPTS : {
183- return handleGetCmdLineOpts ();
184- }
185- case GET_FREE_MONITORING_STATUS : {
186- return handleGetFreeMonitoringStatus ();
187- }
188- case END_SESSIONS : {
168+ case CONNECTION_STATUS -> handleConnectionStatus ();
169+ case HOST_INFO -> handleHostInfo ();
170+ case GET_CMD_LINE_OPTS -> handleGetCmdLineOpts ();
171+ case GET_FREE_MONITORING_STATUS -> handleGetFreeMonitoringStatus ();
172+ case END_SESSIONS -> {
189173 log .debug ("endSessions on admin database" );
190- return successResponse ();
174+ yield successResponse ();
191175 }
192- default :
193- throw new NoSuchCommandException (command .getQueryValue ());
194- }
176+ default -> throw new NoSuchCommandException (command .getQueryValue ());
177+ };
195178 }
196179
197180 private Document handleListDatabases () {
0 commit comments