All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.ai.metricsadvisor.implementation.models.ChangeThresholdCondition Maven / Gradle / Ivy

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.ai.metricsadvisor.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The ChangeThresholdCondition model.
 */
@Fluent
public final class ChangeThresholdCondition implements JsonSerializable {
    /*
     * change percentage, value range : [0, +∞)
     */
    private double changePercentage;

    /*
     * shift point, value range : [1, +∞)
     */
    private int shiftPoint;

    /*
     * if the withinRange = true, detected data is abnormal when the value falls in the range, in this case
     * anomalyDetectorDirection must be Both
     * if the withinRange = false, detected data is abnormal when the value falls out of the range
     */
    private boolean withinRange;

    /*
     * detection direction
     */
    private AnomalyDetectorDirection anomalyDetectorDirection;

    /*
     * The suppressCondition property.
     */
    private SuppressCondition suppressCondition;

    /**
     * Creates an instance of ChangeThresholdCondition class.
     */
    public ChangeThresholdCondition() {
    }

    /**
     * Get the changePercentage property: change percentage, value range : [0, +∞).
     * 
     * @return the changePercentage value.
     */
    public double getChangePercentage() {
        return this.changePercentage;
    }

    /**
     * Set the changePercentage property: change percentage, value range : [0, +∞).
     * 
     * @param changePercentage the changePercentage value to set.
     * @return the ChangeThresholdCondition object itself.
     */
    public ChangeThresholdCondition setChangePercentage(double changePercentage) {
        this.changePercentage = changePercentage;
        return this;
    }

    /**
     * Get the shiftPoint property: shift point, value range : [1, +∞).
     * 
     * @return the shiftPoint value.
     */
    public int getShiftPoint() {
        return this.shiftPoint;
    }

    /**
     * Set the shiftPoint property: shift point, value range : [1, +∞).
     * 
     * @param shiftPoint the shiftPoint value to set.
     * @return the ChangeThresholdCondition object itself.
     */
    public ChangeThresholdCondition setShiftPoint(int shiftPoint) {
        this.shiftPoint = shiftPoint;
        return this;
    }

    /**
     * Get the withinRange property: if the withinRange = true, detected data is abnormal when the value falls in the
     * range, in this case anomalyDetectorDirection must be Both
     * if the withinRange = false, detected data is abnormal when the value falls out of the range.
     * 
     * @return the withinRange value.
     */
    public boolean isWithinRange() {
        return this.withinRange;
    }

    /**
     * Set the withinRange property: if the withinRange = true, detected data is abnormal when the value falls in the
     * range, in this case anomalyDetectorDirection must be Both
     * if the withinRange = false, detected data is abnormal when the value falls out of the range.
     * 
     * @param withinRange the withinRange value to set.
     * @return the ChangeThresholdCondition object itself.
     */
    public ChangeThresholdCondition setWithinRange(boolean withinRange) {
        this.withinRange = withinRange;
        return this;
    }

    /**
     * Get the anomalyDetectorDirection property: detection direction.
     * 
     * @return the anomalyDetectorDirection value.
     */
    public AnomalyDetectorDirection getAnomalyDetectorDirection() {
        return this.anomalyDetectorDirection;
    }

    /**
     * Set the anomalyDetectorDirection property: detection direction.
     * 
     * @param anomalyDetectorDirection the anomalyDetectorDirection value to set.
     * @return the ChangeThresholdCondition object itself.
     */
    public ChangeThresholdCondition setAnomalyDetectorDirection(AnomalyDetectorDirection anomalyDetectorDirection) {
        this.anomalyDetectorDirection = anomalyDetectorDirection;
        return this;
    }

    /**
     * Get the suppressCondition property: The suppressCondition property.
     * 
     * @return the suppressCondition value.
     */
    public SuppressCondition getSuppressCondition() {
        return this.suppressCondition;
    }

    /**
     * Set the suppressCondition property: The suppressCondition property.
     * 
     * @param suppressCondition the suppressCondition value to set.
     * @return the ChangeThresholdCondition object itself.
     */
    public ChangeThresholdCondition setSuppressCondition(SuppressCondition suppressCondition) {
        this.suppressCondition = suppressCondition;
        return this;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeDoubleField("changePercentage", this.changePercentage);
        jsonWriter.writeIntField("shiftPoint", this.shiftPoint);
        jsonWriter.writeBooleanField("withinRange", this.withinRange);
        jsonWriter.writeStringField("anomalyDetectorDirection",
            this.anomalyDetectorDirection == null ? null : this.anomalyDetectorDirection.toString());
        jsonWriter.writeJsonField("suppressCondition", this.suppressCondition);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of ChangeThresholdCondition from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of ChangeThresholdCondition if the JsonReader was pointing to an instance of it, or null if
     * it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the ChangeThresholdCondition.
     */
    public static ChangeThresholdCondition fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            ChangeThresholdCondition deserializedChangeThresholdCondition = new ChangeThresholdCondition();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("changePercentage".equals(fieldName)) {
                    deserializedChangeThresholdCondition.changePercentage = reader.getDouble();
                } else if ("shiftPoint".equals(fieldName)) {
                    deserializedChangeThresholdCondition.shiftPoint = reader.getInt();
                } else if ("withinRange".equals(fieldName)) {
                    deserializedChangeThresholdCondition.withinRange = reader.getBoolean();
                } else if ("anomalyDetectorDirection".equals(fieldName)) {
                    deserializedChangeThresholdCondition.anomalyDetectorDirection
                        = AnomalyDetectorDirection.fromString(reader.getString());
                } else if ("suppressCondition".equals(fieldName)) {
                    deserializedChangeThresholdCondition.suppressCondition = SuppressCondition.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedChangeThresholdCondition;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy