edu.umd.cs.findbugs.sarif.Message Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spotbugs Show documentation
Show all versions of spotbugs Show documentation
SpotBugs: Because it's easy!
package edu.umd.cs.findbugs.sarif;
import edu.umd.cs.findbugs.annotations.NonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonArray;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* Object which represents {@code message} property.
* @see 3.11 message object
*/
final class Message {
String text;
@NonNull
final List arguments;
Message(@NonNull List arguments) {
this.arguments = Collections.unmodifiableList(Objects.requireNonNull(arguments));
}
JsonObject toJsonObject() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("id", "default");
if (text != null) {
jsonObject.addProperty("text", text);
}
JsonArray jsonArray = new JsonArray();
for (String arg : arguments) {
jsonArray.add(arg);
}
if (jsonArray.size() > 0) {
jsonObject.add("arguments", jsonArray);
}
return jsonObject;
}
}