GetServerInfo: Use java.util.Optional

Change-Id: I4949abfe8f8ffb2c47b9e49b6062d870749a6183
This commit is contained in:
Dave Borowitz
2016-10-13 16:14:35 -04:00
parent 21782e8443
commit 8fc529157e

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.config;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import com.google.common.base.Optional;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.common.data.ContributorAgreement; import com.google.gerrit.common.data.ContributorAgreement;
@@ -62,6 +61,7 @@ import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class GetServerInfo implements RestReadView<ConfigResource> { public class GetServerInfo implements RestReadView<ConfigResource> {
@@ -215,11 +215,11 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
.hasField(ChangeField.ASSIGNEE)); .hasField(ChangeField.ASSIGNEE));
info.largeChange = cfg.getInt("change", "largeChange", 500); info.largeChange = cfg.getInt("change", "largeChange", 500);
info.replyTooltip = info.replyTooltip =
Optional.fromNullable(cfg.getString("change", null, "replyTooltip")) Optional.ofNullable(cfg.getString("change", null, "replyTooltip"))
.or("Reply and score") + " (Shortcut: a)"; .orElse("Reply and score") + " (Shortcut: a)";
info.replyLabel = info.replyLabel =
Optional.fromNullable(cfg.getString("change", null, "replyLabel")) Optional.ofNullable(cfg.getString("change", null, "replyLabel"))
.or("Reply") + "\u2026"; .orElse("Reply") + "\u2026";
info.updateDelay = (int) ConfigUtil.getTimeUnit( info.updateDelay = (int) ConfigUtil.getTimeUnit(
cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS); cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS);
info.submitWholeTopic = Submit.wholeTopicEnabled(cfg); info.submitWholeTopic = Submit.wholeTopicEnabled(cfg);