]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA remove Optional<> method parameter
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Thu, 30 Mar 2023 14:11:18 +0000 (16:11 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 30 Mar 2023 20:03:08 +0000 (20:03 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java

index 5cc43f25ef70010cedb97e661eba052017b9bcf6..fc91e750c0a68386aa56cc5a5dc9c35d3a3c0af1 100644 (file)
@@ -125,7 +125,7 @@ public class SearchAction implements UserGroupsWsAction {
 
   private GroupQuery buildGroupQuery(Request request) {
     String textQuery = request.param(Param.TEXT_QUERY);
-    Optional<Boolean> managed = Optional.ofNullable(request.paramAsBoolean(MANAGED_PARAM));
+    Boolean managed = request.paramAsBoolean(MANAGED_PARAM);
 
     GroupQuery.GroupQueryBuilder queryBuilder = GroupQuery.builder()
       .searchText(textQuery);
@@ -133,7 +133,7 @@ public class SearchAction implements UserGroupsWsAction {
     if (managedInstanceService.isInstanceExternallyManaged()) {
       String managedInstanceSql = getManagedInstanceSql(managed);
       queryBuilder.isManagedClause(managedInstanceSql);
-    } else if (managed.isPresent()) {
+    } else if (TRUE.equals(managed)) {
       throw BadRequestException.create("The 'managed' parameter is only available for managed instances.");
     }
     return queryBuilder.build();
@@ -141,8 +141,8 @@ public class SearchAction implements UserGroupsWsAction {
   }
 
   @Nullable
-  private String getManagedInstanceSql(Optional<Boolean> managed) {
-    return managed
+  private String getManagedInstanceSql(@Nullable Boolean managed) {
+    return Optional.ofNullable(managed)
       .map(managedInstanceService::getManagedGroupsSqlFilter)
       .orElse(null);
   }