com.boonamber.models.AnalyticResults Maven / Gradle / Ivy
The newest version!
/*
* Amber API Server
* Boon Logic Amber API server
*
* The version of the OpenAPI document: 2.0.0
*
*
* 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.boonamber.models;
import java.util.Objects;
import java.util.Arrays;
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.List;
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 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.boonamber.JSON;
/**
* AnalyticResults
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class AnalyticResults {
public static final String SERIALIZED_NAME_A_D = "AD";
@SerializedName(SERIALIZED_NAME_A_D)
private List AD = new ArrayList<>();
public static final String SERIALIZED_NAME_A_H = "AH";
@SerializedName(SERIALIZED_NAME_A_H)
private List AH = new ArrayList<>();
public static final String SERIALIZED_NAME_A_W = "AW";
@SerializedName(SERIALIZED_NAME_A_W)
private List AW = new ArrayList<>();
public static final String SERIALIZED_NAME_I_D = "ID";
@SerializedName(SERIALIZED_NAME_I_D)
private List ID = new ArrayList<>();
public static final String SERIALIZED_NAME_N_I = "NI";
@SerializedName(SERIALIZED_NAME_N_I)
private List NI = new ArrayList<>();
public static final String SERIALIZED_NAME_N_S = "NS";
@SerializedName(SERIALIZED_NAME_N_S)
private List NS = new ArrayList<>();
public static final String SERIALIZED_NAME_N_W = "NW";
@SerializedName(SERIALIZED_NAME_N_W)
private List NW = new ArrayList<>();
public static final String SERIALIZED_NAME_C_S = "CS";
@SerializedName(SERIALIZED_NAME_C_S)
private List CS = new ArrayList<>();
public static final String SERIALIZED_NAME_O_M = "OM";
@SerializedName(SERIALIZED_NAME_O_M)
private List OM = new ArrayList<>();
public static final String SERIALIZED_NAME_R_I = "RI";
@SerializedName(SERIALIZED_NAME_R_I)
private List RI = new ArrayList<>();
public static final String SERIALIZED_NAME_S_I = "SI";
@SerializedName(SERIALIZED_NAME_S_I)
private List SI = new ArrayList<>();
public static final String SERIALIZED_NAME_P_I = "PI";
@SerializedName(SERIALIZED_NAME_P_I)
private List PI = new ArrayList<>();
public AnalyticResults() {
}
public AnalyticResults AD(List AD) {
this.AD = AD;
return this;
}
public AnalyticResults addADItem(Integer ADItem) {
if (this.AD == null) {
this.AD = new ArrayList<>();
}
this.AD.add(ADItem);
return this;
}
/**
* A binary array where 1 means a pattern was anomalous and 0 means normal. This value is derived by thresholding the `anomalyIndex`.
* @return AD
**/
@javax.annotation.Nullable
public List getAD() {
return AD;
}
public void setAD(List AD) {
this.AD = AD;
}
public AnalyticResults AH(List AH) {
this.AH = AH;
return this;
}
public AnalyticResults addAHItem(Integer AHItem) {
if (this.AH == null) {
this.AH = new ArrayList<>();
}
this.AH.add(AHItem);
return this;
}
/**
* The number of anomalous patterns in the last `historyWindow` samples. Specifically, this is a moving-window sum of the `anomalyDetection` array with window length `historyWindow`.
* @return AH
**/
@javax.annotation.Nullable
public List getAH() {
return AH;
}
public void setAH(List AH) {
this.AH = AH;
}
public AnalyticResults AW(List AW) {
this.AW = AW;
return this;
}
public AnalyticResults addAWItem(Integer AWItem) {
if (this.AW == null) {
this.AW = new ArrayList<>();
}
this.AW.add(AWItem);
return this;
}
/**
* Amber warning level at each sample, a measure of the compliance of recent behavior compared to behavior observed during `Learning`. This value is derived from `recentAnomalies` and a statistical model of expectations about the usual frequency of anomalies. - `0`: OK - `1`: asset changing - `2`: asset critical
* @return AW
**/
@javax.annotation.Nullable
public List getAW() {
return AW;
}
public void setAW(List AW) {
this.AW = AW;
}
public AnalyticResults ID(List ID) {
this.ID = ID;
return this;
}
public AnalyticResults addIDItem(Integer IDItem) {
if (this.ID == null) {
this.ID = new ArrayList<>();
}
this.ID.add(IDItem);
return this;
}
/**
* The cluster to which each input pattern was assigned. The first pattern is assigned a `clusterId` of 1. Each pattern thereafter is either assigned to an existing cluster (if its distance from that cluster is less than `percentVariation`) or creates a new cluster (if its distance from all clusters exceeds `percentVariation`). The `clusterId` for each new cluster is the current maximum `clusterId` plus one. For example, a model with 10 clusters will have `clusterIds` 1-10, and the next new cluster will have `clusterId` 11. During `Monitoring`, the cluster model becomes frozen and no new clusters are formed. Patterns which cannot be assigned to any existing cluster will return a negative `clusterId`. These `clusterIds` start at -1 and decreasing strictly by 1 without repeating (they can be used for root cause analysis).
* @return ID
**/
@javax.annotation.Nullable
public List getID() {
return ID;
}
public void setID(List ID) {
this.ID = ID;
}
public AnalyticResults NI(List NI) {
this.NI = NI;
return this;
}
public AnalyticResults addNIItem(Integer NIItem) {
if (this.NI == null) {
this.NI = new ArrayList<>();
}
this.NI.add(NIItem);
return this;
}
/**
* See Boon Docs.
* @return NI
**/
@javax.annotation.Nullable
public List getNI() {
return NI;
}
public void setNI(List NI) {
this.NI = NI;
}
public AnalyticResults NS(List NS) {
this.NS = NS;
return this;
}
public AnalyticResults addNSItem(Integer NSItem) {
if (this.NS == null) {
this.NS = new ArrayList<>();
}
this.NS.add(NSItem);
return this;
}
/**
* See Boon Docs.
* @return NS
**/
@javax.annotation.Nullable
public List getNS() {
return NS;
}
public void setNS(List NS) {
this.NS = NS;
}
public AnalyticResults NW(List NW) {
this.NW = NW;
return this;
}
public AnalyticResults addNWItem(Float NWItem) {
if (this.NW == null) {
this.NW = new ArrayList<>();
}
this.NW.add(NWItem);
return this;
}
/**
* See Boon Docs.
* @return NW
**/
@javax.annotation.Nullable
public List getNW() {
return NW;
}
public void setNW(List NW) {
this.NW = NW;
}
public AnalyticResults CS(List CS) {
this.CS = CS;
return this;
}
public AnalyticResults addCSItem(Integer CSItem) {
if (this.CS == null) {
this.CS = new ArrayList<>();
}
this.CS.add(CSItem);
return this;
}
/**
* See Boon Docs.
* @return CS
**/
@javax.annotation.Nullable
public List getCS() {
return CS;
}
public void setCS(List CS) {
this.CS = CS;
}
public AnalyticResults OM(List OM) {
this.OM = OM;
return this;
}
public AnalyticResults addOMItem(Float OMItem) {
if (this.OM == null) {
this.OM = new ArrayList<>();
}
this.OM.add(OMItem);
return this;
}
/**
* See Boon Docs.
* @return OM
**/
@javax.annotation.Nullable
public List getOM() {
return OM;
}
public void setOM(List OM) {
this.OM = OM;
}
public AnalyticResults RI(List RI) {
this.RI = RI;
return this;
}
public AnalyticResults addRIItem(Integer RIItem) {
if (this.RI == null) {
this.RI = new ArrayList<>();
}
this.RI.add(RIItem);
return this;
}
/**
* An integer between 0 and 1000 giving a measure of how anomalous this pattern is compared to patterns seen in the past. Values closer to 0 represent patterns which are ordinary given the data seen so far on this model, while values closer to 1000 represent anomalous patterns. Patterns with a high `anomalyIndex` belong to clusters with relatively few patterns compared to the other clusters.
* @return RI
**/
@javax.annotation.Nullable
public List getRI() {
return RI;
}
public void setRI(List RI) {
this.RI = RI;
}
public AnalyticResults SI(List SI) {
this.SI = SI;
return this;
}
public AnalyticResults addSIItem(Integer SIItem) {
if (this.SI == null) {
this.SI = new ArrayList<>();
}
this.SI.add(SIItem);
return this;
}
/**
* Exponentially smoothed `anomalyIndex` over the last 15 samples. The range remains between 0 and 1000.
* @return SI
**/
@javax.annotation.Nullable
public List getSI() {
return SI;
}
public void setSI(List SI) {
this.SI = SI;
}
public AnalyticResults PI(List PI) {
this.PI = PI;
return this;
}
public AnalyticResults addPIItem(Integer PIItem) {
if (this.PI == null) {
this.PI = new ArrayList<>();
}
this.PI.add(PIItem);
return this;
}
/**
* An anomaly index that represents the probability within the model of getting that cluster. PI is scaled so that 0 is the most probable cluster (least anomalous) and values close to 1000 represent very improbable clusters, that is, that very rarely occurred during training.
* @return PI
**/
@javax.annotation.Nullable
public List getPI() {
return PI;
}
public void setPI(List PI) {
this.PI = PI;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AnalyticResults analyticResults = (AnalyticResults) o;
return Objects.equals(this.AD, analyticResults.AD) &&
Objects.equals(this.AH, analyticResults.AH) &&
Objects.equals(this.AW, analyticResults.AW) &&
Objects.equals(this.ID, analyticResults.ID) &&
Objects.equals(this.NI, analyticResults.NI) &&
Objects.equals(this.NS, analyticResults.NS) &&
Objects.equals(this.NW, analyticResults.NW) &&
Objects.equals(this.CS, analyticResults.CS) &&
Objects.equals(this.OM, analyticResults.OM) &&
Objects.equals(this.RI, analyticResults.RI) &&
Objects.equals(this.SI, analyticResults.SI) &&
Objects.equals(this.PI, analyticResults.PI);
}
@Override
public int hashCode() {
return Objects.hash(AD, AH, AW, ID, NI, NS, NW, CS, OM, RI, SI, PI);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class AnalyticResults {\n");
sb.append(" AD: ").append(toIndentedString(AD)).append("\n");
sb.append(" AH: ").append(toIndentedString(AH)).append("\n");
sb.append(" AW: ").append(toIndentedString(AW)).append("\n");
sb.append(" ID: ").append(toIndentedString(ID)).append("\n");
sb.append(" NI: ").append(toIndentedString(NI)).append("\n");
sb.append(" NS: ").append(toIndentedString(NS)).append("\n");
sb.append(" NW: ").append(toIndentedString(NW)).append("\n");
sb.append(" CS: ").append(toIndentedString(CS)).append("\n");
sb.append(" OM: ").append(toIndentedString(OM)).append("\n");
sb.append(" RI: ").append(toIndentedString(RI)).append("\n");
sb.append(" SI: ").append(toIndentedString(SI)).append("\n");
sb.append(" PI: ").append(toIndentedString(PI)).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("AD");
openapiFields.add("AH");
openapiFields.add("AW");
openapiFields.add("ID");
openapiFields.add("NI");
openapiFields.add("NS");
openapiFields.add("NW");
openapiFields.add("CS");
openapiFields.add("OM");
openapiFields.add("RI");
openapiFields.add("SI");
openapiFields.add("PI");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to AnalyticResults
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!AnalyticResults.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AnalyticResults is not found in the empty JSON string", AnalyticResults.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AnalyticResults.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AnalyticResults` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
}
}
// ensure the optional json data is an array if present
if (jsonObj.get("AD") != null && !jsonObj.get("AD").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `AD` to be an array in the JSON string but got `%s`", jsonObj.get("AD").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("AH") != null && !jsonObj.get("AH").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `AH` to be an array in the JSON string but got `%s`", jsonObj.get("AH").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("AW") != null && !jsonObj.get("AW").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `AW` to be an array in the JSON string but got `%s`", jsonObj.get("AW").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("ID") != null && !jsonObj.get("ID").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `ID` to be an array in the JSON string but got `%s`", jsonObj.get("ID").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("NI") != null && !jsonObj.get("NI").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `NI` to be an array in the JSON string but got `%s`", jsonObj.get("NI").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("NS") != null && !jsonObj.get("NS").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `NS` to be an array in the JSON string but got `%s`", jsonObj.get("NS").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("NW") != null && !jsonObj.get("NW").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `NW` to be an array in the JSON string but got `%s`", jsonObj.get("NW").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("CS") != null && !jsonObj.get("CS").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `CS` to be an array in the JSON string but got `%s`", jsonObj.get("CS").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("OM") != null && !jsonObj.get("OM").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `OM` to be an array in the JSON string but got `%s`", jsonObj.get("OM").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("RI") != null && !jsonObj.get("RI").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `RI` to be an array in the JSON string but got `%s`", jsonObj.get("RI").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("SI") != null && !jsonObj.get("SI").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `SI` to be an array in the JSON string but got `%s`", jsonObj.get("SI").toString()));
}
// ensure the optional json data is an array if present
if (jsonObj.get("PI") != null && !jsonObj.get("PI").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `PI` to be an array in the JSON string but got `%s`", jsonObj.get("PI").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!AnalyticResults.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'AnalyticResults' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(AnalyticResults.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, AnalyticResults value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public AnalyticResults read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of AnalyticResults given an JSON string
*
* @param jsonString JSON string
* @return An instance of AnalyticResults
* @throws IOException if the JSON string is invalid with respect to AnalyticResults
*/
public static AnalyticResults fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, AnalyticResults.class);
}
/**
* Convert an instance of AnalyticResults to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}