aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-11-16 10:02:12 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-11-16 10:02:12 +0100
commit9774527d9e469c6590beb4cc4042e48a41f51b81 (patch)
tree8a23a2b2d7a8d423f4a266d4287c6c80c9660815 /server/sonar-server
parentb86cbb539986c2e2e70b09c608008367fae81a89 (diff)
downloadsonarqube-9774527d9e469c6590beb4cc4042e48a41f51b81.tar.gz
sonarqube-9774527d9e469c6590beb4cc4042e48a41f51b81.zip
Decrease complexity of org.sonar.server.projectlink.ws.SearchAction
Minor change on null conditions when using protobuf builders.
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/SearchAction.java9
1 files changed, 3 insertions, 6 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/SearchAction.java
index 726b74bf409..2e041d135d4 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/projectlink/ws/SearchAction.java
@@ -35,6 +35,7 @@ import org.sonarqube.ws.WsProjectLinks.Link;
import org.sonarqube.ws.WsProjectLinks.SearchWsResponse;
import org.sonarqube.ws.client.projectlinks.SearchWsRequest;
+import static org.sonar.core.util.Protobuf.setNullable;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
@@ -111,12 +112,8 @@ public class SearchAction implements ProjectLinksWsAction {
Link.Builder builder = Link.newBuilder()
.setId(String.valueOf(link.getId()))
.setUrl(link.getHref());
- if (link.getName() != null) {
- builder.setName(link.getName());
- }
- if (link.getType() != null) {
- builder.setType(link.getType());
- }
+ setNullable(link.getName(), builder::setName);
+ setNullable(link.getType(), builder::setType);
return builder.build();
}