aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-06-28 09:12:05 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-06-28 09:12:05 +0200
commit8cde393f76fcdd368efe41664a02f97b4b7a6747 (patch)
tree40e48119e4a2b9b29682712353e3adea83c47edc /sonar-ws-client
parent1c02ab27903725462417d4bdc71f0dfaab899f3b (diff)
downloadsonarqube-8cde393f76fcdd368efe41664a02f97b4b7a6747.tar.gz
sonarqube-8cde393f76fcdd368efe41664a02f97b4b7a6747.zip
Fix quality flaws
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java8
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java8
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java9
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java11
4 files changed, 35 insertions, 1 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java
index 358a7e06868..90aff336e9c 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java
@@ -24,6 +24,8 @@ import org.json.simple.JSONValue;
import org.sonar.wsclient.services.WSUtils;
import org.sonar.wsclient.unmarshallers.JsonUtils;
+import javax.annotation.CheckForNull;
+
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
@@ -55,31 +57,37 @@ public final class JdkUtils extends WSUtils {
}
@Override
+ @CheckForNull
public String getString(Object json, String field) {
return JsonUtils.getString((JSONObject) json, field);
}
@Override
+ @CheckForNull
public Boolean getBoolean(Object json, String field) {
return JsonUtils.getBoolean((JSONObject) json, field);
}
@Override
+ @CheckForNull
public Integer getInteger(Object json, String field) {
return JsonUtils.getInteger((JSONObject) json, field);
}
@Override
+ @CheckForNull
public Double getDouble(Object json, String field) {
return JsonUtils.getDouble((JSONObject) json, field);
}
@Override
+ @CheckForNull
public Long getLong(Object json, String field) {
return JsonUtils.getLong((JSONObject) json, field);
}
@Override
+ @CheckForNull
public Date getDateTime(Object json, String field) {
return JsonUtils.getDateTime((JSONObject) json, field);
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java
index d74671e54da..a0fbdaf0e27 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java
@@ -19,6 +19,9 @@
*/
package org.sonar.wsclient.services;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
/**
* @since 2.5
*/
@@ -29,21 +32,24 @@ public class TimeMachineColumn {
private String modelName;
private String characteristicKey;
- public TimeMachineColumn(int index, String metricKey, String modelName, String characteristicKey) {
+ public TimeMachineColumn(int index, @Nullable String metricKey, @Nullable String modelName, @Nullable String characteristicKey) {
this.index = index;
this.metricKey = metricKey;
this.modelName = modelName;
this.characteristicKey = characteristicKey;
}
+ @CheckForNull
public String getMetricKey() {
return metricKey;
}
+ @CheckForNull
public String getModelName() {
return modelName;
}
+ @CheckForNull
public String getCharacteristicKey() {
return characteristicKey;
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
index 516bf99cb0f..d81ff0e834a 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
@@ -19,6 +19,8 @@
*/
package org.sonar.wsclient.services;
+import javax.annotation.CheckForNull;
+
import java.util.Date;
import java.util.Set;
@@ -47,6 +49,7 @@ public abstract class WSUtils {
* @return value of specified field from specified JSON object,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract Object getField(Object json, String field);
/**
@@ -54,36 +57,42 @@ public abstract class WSUtils {
* or string representation of a numeric field,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract String getString(Object json, String field);
/**
* @return Boolean value of specified field from specified JSON object,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract Boolean getBoolean(Object json, String field);
/**
* @return Integer value of specified field from specified JSON object,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract Integer getInteger(Object json, String field);
/**
* @return Double value of specified field from specified JSON object,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract Double getDouble(Object json, String field);
/**
* @return Long value of specified field from specified JSON object,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract Long getLong(Object json, String field);
/**
* @return Date value of specified field from specified JSON object,
* or <code>null</code> if field does not exist
*/
+ @CheckForNull
public abstract Date getDateTime(Object json, String field);
/**
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java
index c767b5602f4..943974d2c3e 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java
@@ -21,6 +21,8 @@ package org.sonar.wsclient.unmarshallers;
import org.json.simple.JSONArray;
+import javax.annotation.CheckForNull;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -34,6 +36,7 @@ public final class JsonUtils {
// only static methods
}
+ @CheckForNull
public static String getString(Map obj, String field) {
Object value = obj.get(field);
if (value instanceof String || value instanceof Number) {
@@ -42,6 +45,7 @@ public final class JsonUtils {
return null;
}
+ @CheckForNull
public static Integer getInteger(Map obj, String field) {
Object value = obj.get(field);
if (value != null) {
@@ -50,6 +54,7 @@ public final class JsonUtils {
return null;
}
+ @CheckForNull
public static Boolean getBoolean(Map obj, String field) {
Object value = obj.get(field);
if (value != null) {
@@ -58,6 +63,7 @@ public final class JsonUtils {
return null;
}
+ @CheckForNull
public static Long getLong(Map obj, String field) {
Object value = obj.get(field);
if (value != null) {
@@ -66,6 +72,7 @@ public final class JsonUtils {
return null;
}
+ @CheckForNull
public static Double getDouble(Map obj, String field) {
Object value = obj.get(field);
if (value != null) {
@@ -80,18 +87,22 @@ public final class JsonUtils {
/**
* @since 2.5
*/
+ @CheckForNull
public static JSONArray getArray(Map obj, String field) {
return (JSONArray) obj.get(field);
}
+ @CheckForNull
public static Date getDateTime(Map obj, String field) {
return parseDate(obj, field, "yyyy-MM-dd'T'HH:mm:ssZ");
}
+ @CheckForNull
public static Date getDate(Map obj, String field) {
return parseDate(obj, field, "yyyy-MM-dd");
}
+ @CheckForNull
private static Date parseDate(Map obj, String field, String format) {
String value = getString(obj, field);
if (value != null) {