Skip to content

Commit

Permalink
SONAR-11513 drop Guava Optional from ActiveRulesHolder
Browse files Browse the repository at this point in the history
  • Loading branch information
sns-seb authored and SonarTech committed Dec 3, 2018
1 parent 9320207 commit a11e761
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
*/
package org.sonar.ce.task.projectanalysis.issue.commonrule;

import com.google.common.base.Optional;
import java.util.Optional;
import javax.annotation.CheckForNull;
import org.sonar.api.rule.RuleKey;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule;
import org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRulesHolder;
import org.sonar.core.issue.DefaultIssue;

import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.sonar.server.rule.CommonRuleKeys.commonRepositoryForLang;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.Optional;
import org.sonar.api.rule.RuleKey;

public interface ActiveRulesHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.sonar.api.rule.RuleKey;

import static com.google.common.base.Preconditions.checkState;
Expand All @@ -36,7 +36,7 @@ public class ActiveRulesHolderImpl implements ActiveRulesHolder {
@Override
public Optional<ActiveRule> get(RuleKey ruleKey) {
checkState(activeRulesByKey != null, "Active rules have not been initialized yet");
return Optional.fromNullable(activeRulesByKey.get(ruleKey));
return Optional.ofNullable(activeRulesByKey.get(ruleKey));
}

public Collection<ActiveRule> getAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/
package org.sonar.ce.task.projectanalysis.issue;

import com.google.common.base.Optional;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void before() {

when(ruleRepository.findByKey(ruleKey)).thenReturn(java.util.Optional.of(rule));
when(activeRulesHolder.get(any(RuleKey.class)))
.thenReturn(Optional.absent());
.thenReturn(Optional.empty());
when(activeRulesHolder.get(ruleKey))
.thenReturn(Optional.of(activeRule));
when(issue.getRuleKey())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.Collections;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.junit.rules.ExternalResource;
import org.sonar.api.rule.RuleKey;

Expand All @@ -31,7 +31,7 @@ public class ActiveRulesHolderRule extends ExternalResource implements ActiveRul

@Override
public Optional<ActiveRule> get(RuleKey ruleKey) {
return Optional.fromNullable(activeRulesByKey.get(ruleKey));
return Optional.ofNullable(activeRulesByKey.get(ruleKey));
}

public ActiveRulesHolderRule put(ActiveRule activeRule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
package org.sonar.ce.task.projectanalysis.qualityprofile;

import com.google.common.base.Optional;
import java.util.Optional;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
package org.sonar.ce.task.projectanalysis.step;

import com.google.common.base.Optional;
import java.util.Optional;
import org.assertj.core.data.MapEntry;
import org.junit.Rule;
import org.junit.Test;
Expand Down

0 comments on commit a11e761

Please sign in to comment.