Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* FINBOURNE Scheduler API
*
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.finbourne.scheduler.model;
import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.finbourne.scheduler.JSON;
/**
* Represents the details of an image vulnerability
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class Vulnerability {
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_PACKAGE = "package";
@SerializedName(SERIALIZED_NAME_PACKAGE)
private String _package;
public static final String SERIALIZED_NAME_VERSION = "version";
@SerializedName(SERIALIZED_NAME_VERSION)
private String version;
public static final String SERIALIZED_NAME_FIX_VERSION = "fixVersion";
@SerializedName(SERIALIZED_NAME_FIX_VERSION)
private String fixVersion;
public static final String SERIALIZED_NAME_SEVERITY = "severity";
@SerializedName(SERIALIZED_NAME_SEVERITY)
private String severity;
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public static final String SERIALIZED_NAME_LINKS = "links";
@SerializedName(SERIALIZED_NAME_LINKS)
private List links;
public Vulnerability() {
}
public Vulnerability name(String name) {
this.name = name;
return this;
}
/**
* The name of the vulnerability
* @return name
**/
@jakarta.annotation.Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vulnerability _package(String _package) {
this._package = _package;
return this;
}
/**
* The package that contains the vulnerability
* @return _package
**/
@jakarta.annotation.Nullable
public String getPackage() {
return _package;
}
public void setPackage(String _package) {
this._package = _package;
}
public Vulnerability version(String version) {
this.version = version;
return this;
}
/**
* The version of the package
* @return version
**/
@jakarta.annotation.Nullable
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Vulnerability fixVersion(String fixVersion) {
this.fixVersion = fixVersion;
return this;
}
/**
* The version that has a fix for the vulnerability (if known)
* @return fixVersion
**/
@jakarta.annotation.Nullable
public String getFixVersion() {
return fixVersion;
}
public void setFixVersion(String fixVersion) {
this.fixVersion = fixVersion;
}
public Vulnerability severity(String severity) {
this.severity = severity;
return this;
}
/**
* The severity of the vulnerability
* @return severity
**/
@jakarta.annotation.Nullable
public String getSeverity() {
return severity;
}
public void setSeverity(String severity) {
this.severity = severity;
}
public Vulnerability description(String description) {
this.description = description;
return this;
}
/**
* The description of the vulnerability
* @return description
**/
@jakarta.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Vulnerability links(List links) {
this.links = links;
return this;
}
public Vulnerability addLinksItem(String linksItem) {
if (this.links == null) {
this.links = new ArrayList<>();
}
this.links.add(linksItem);
return this;
}
/**
* Relevant links for the vulnerability
* @return links
**/
@jakarta.annotation.Nullable
public List getLinks() {
return links;
}
public void setLinks(List links) {
this.links = links;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Vulnerability vulnerability = (Vulnerability) o;
return Objects.equals(this.name, vulnerability.name) &&
Objects.equals(this._package, vulnerability._package) &&
Objects.equals(this.version, vulnerability.version) &&
Objects.equals(this.fixVersion, vulnerability.fixVersion) &&
Objects.equals(this.severity, vulnerability.severity) &&
Objects.equals(this.description, vulnerability.description) &&
Objects.equals(this.links, vulnerability.links);
}
private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}
@Override
public int hashCode() {
return Objects.hash(name, _package, version, fixVersion, severity, description, links);
}
private static int hashCodeNullable(JsonNullable a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Vulnerability {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" _package: ").append(toIndentedString(_package)).append("\n");
sb.append(" version: ").append(toIndentedString(version)).append("\n");
sb.append(" fixVersion: ").append(toIndentedString(fixVersion)).append("\n");
sb.append(" severity: ").append(toIndentedString(severity)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" links: ").append(toIndentedString(links)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static HashSet openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("name");
openapiFields.add("package");
openapiFields.add("version");
openapiFields.add("fixVersion");
openapiFields.add("severity");
openapiFields.add("description");
openapiFields.add("links");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Element and throws an exception if issues found
*
* @param jsonElement JSON Element
* @throws IOException if the JSON Element is invalid with respect to Vulnerability
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!Vulnerability.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Vulnerability is not found in the empty JSON string", Vulnerability.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
}
if ((jsonObj.get("package") != null && !jsonObj.get("package").isJsonNull()) && !jsonObj.get("package").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `package` to be a primitive type in the JSON string but got `%s`", jsonObj.get("package").toString()));
}
if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull()) && !jsonObj.get("version").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString()));
}
if ((jsonObj.get("fixVersion") != null && !jsonObj.get("fixVersion").isJsonNull()) && !jsonObj.get("fixVersion").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `fixVersion` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fixVersion").toString()));
}
if ((jsonObj.get("severity") != null && !jsonObj.get("severity").isJsonNull()) && !jsonObj.get("severity").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `severity` to be a primitive type in the JSON string but got `%s`", jsonObj.get("severity").toString()));
}
if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull() && !jsonObj.get("links").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!Vulnerability.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'Vulnerability' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(Vulnerability.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, Vulnerability value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public Vulnerability read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of Vulnerability given an JSON string
*
* @param jsonString JSON string
* @return An instance of Vulnerability
* @throws IOException if the JSON string is invalid with respect to Vulnerability
*/
public static Vulnerability fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, Vulnerability.class);
}
/**
* Convert an instance of Vulnerability to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}