From 7d562d641868532e5edbd6f03fac739eff9bcc90 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 9 Oct 2014 23:35:41 +0200 Subject: Fix quality flaws --- .../src/main/java/org/sonar/colorizer/CodeColorizer.java | 4 +++- .../src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java | 6 +++++- sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'sonar-colorizer') diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java index bf1fe61df74..4c8695843c3 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java @@ -19,6 +19,8 @@ */ package org.sonar.colorizer; +import javax.annotation.Nullable; + import java.io.Reader; import java.util.List; @@ -38,7 +40,7 @@ public class CodeColorizer { return toHtml(code, null); } - public String toHtml(Reader code, HtmlOptions options) { + public String toHtml(Reader code, @Nullable HtmlOptions options) { HtmlOptions opts = options == null ? HtmlOptions.DEFAULT : options; return new HtmlRenderer(opts).render(code, tokenizers); } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java index e6755e7b7e7..c7f9f3d3a7e 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java @@ -19,6 +19,9 @@ */ package org.sonar.colorizer; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + import java.util.HashMap; import java.util.Map; @@ -75,13 +78,14 @@ public class HtmlCodeBuilder implements Appendable { * @param value * can be null */ - public void setVariable(Object key, Object value) { + public void setVariable(Object key, @Nullable Object value) { variables.put(key, value); } /** * Get a stateful variable. Return null if not found. */ + @CheckForNull public Object getVariable(Object key) { return variables.get(key); } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java index d91d89bf5e7..da86bc689c0 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java @@ -19,6 +19,9 @@ */ package org.sonar.colorizer; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + public class HtmlOptions { public static final HtmlOptions DEFAULT = new HtmlOptions(true, null, true); public static final OnlySyntaxHtmlOptions ONLY_SYNTAX = new OnlySyntaxHtmlOptions(); @@ -31,7 +34,7 @@ public class HtmlOptions { public HtmlOptions() { } - public HtmlOptions(boolean generateTable, String tableId, boolean generateHtmlHeader) { + public HtmlOptions(boolean generateTable, @Nullable String tableId, boolean generateHtmlHeader) { this.generateTable = generateTable; this.generateHtmlHeader = generateHtmlHeader; this.tableId = tableId; @@ -61,6 +64,7 @@ public class HtmlOptions { return this; } + @CheckForNull public String getTableId() { return tableId; } -- cgit v1.2.3