com.vmware.ovsdb.protocol.operation.notation.Condition Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2018 VMware, Inc. All Rights Reserved.
*
* This product is licensed to you under the BSD-2 license (the "License").
* You may not use this product except in compliance with the BSD-2 License.
*
* This product may include a number of subcomponents with separate copyright
* notices and license terms. Your use of these subcomponents is subject to the
* terms and conditions of the subcomponent's license, as noted in the LICENSE
* file.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
package com.vmware.ovsdb.protocol.operation.notation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.vmware.ovsdb.protocol.operation.notation.deserializer.ConditionDeserializer;
import java.util.Objects;
/**
* Representation of {@literal }.
*
*
* {@literal
*
* A 3-element JSON array of the form [, , ]
* that represents a test on a column value. Except as otherwise
* specified below, MUST have the same type as . The
* meaning depends on the type of :
*
* integer or real
* must be "<", "<=", "==", "!=", ">=", ">",
* "includes", or "excludes".
*
* The test is true if the column's value satisfies the relation
* , e.g., if the column has value 1 and
* is 2, the test is true if is "<", "<=", or "!=", but
* not otherwise.
*
* "includes" is equivalent to "=="; "excludes" is equivalent to
* "!=".
*
* boolean or string or uuid
* must be "!=", "==", "includes", or "excludes".
*
* If is "==" or "includes", the test is true if the
* column's value equals . If is "!=" or
* "excludes", the test is inverted.
*
* set or map
* must be "!=", "==", "includes", or "excludes".
*
* If is "==", the test is true if the column's value
* contains exactly the same values (for sets) or pairs (for
* maps). If is "!=", the test is inverted.
*
* If is "includes", the test is true if the column's
* value contains all of the values (for sets) or pairs (for maps)
* in . The column's value may also contain other values
* or pairs.
*
* If is "excludes", the test is true if the column's
* value does not contain any of the values (for sets) or pairs
* (for maps) in . The column's value may contain other
* values or pairs not in .
*
* If is "includes" or "excludes", then the required
* type of is slightly relaxed, in that it may have fewer
* than the minimum number of elements specified by the column's
* type. If is "excludes", then the required type is
* additionally relaxed in that may have more than the
* maximum number of elements specified by the column's type.
* }
*
*/
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
@JsonDeserialize(using = ConditionDeserializer.class)
public class Condition {
private final String column;
private final Function function;
private final Value value;
/**
* Create a {@link Condition} object.
*
* @param column value of the "column" field
* @param function value of the "function" field
* @param value value of the "value" field
*/
public Condition(String column, Function function, Value value) {
this.column = column;
this.function = function;
this.value = value;
}
public String getColumn() {
return column;
}
public Function getFunction() {
return function;
}
public Object getValue() {
return value;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Condition)) {
return false;
}
Condition condition = (Condition) other;
return Objects.equals(column, condition.getColumn())
&& function == condition.getFunction()
&& Objects.equals(value, condition.getValue());
}
@Override
public int hashCode() {
return Objects.hash(column, function, value);
}
@Override
public String toString() {
return getClass().getSimpleName() + " ["
+ "column=" + column
+ ", function=" + function
+ ", value=" + value
+ "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy