com.vmware.ovsdb.protocol.operation.notation.Mutation 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 java.util.Objects;
/**
* Representation of {@literal }.
*
*
* {@literal
*
* A 3-element JSON array of the form [, , ]
* that represents a change to 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 "+=", "-=", "*=", "/=", or (integer only)
* "%=". The value of is changed to the sum, difference,
* product, quotient, or remainder, respectively, of and
* .
*
* Constraints on are ignored when parsing .
*
* boolean, string, or uuid
* No valid s are currently defined for these types.
*
* set
* Any valid for the set's element type may be applied
* to the set, in which case the mutation is applied to each
* member of the set individually. must be a scalar value
* of the same type as the set's element type, except that
* constraints are ignored when parsing .
*
* If is "insert", then each of the values in the set in
* is added to if it is not already present. 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 "delete", then each of the values in the set in
* is removed from if it is present there. The
* required type is slightly relaxed in that may have more
* or less than the maximum number of elements specified by the
* column's type.
*
* map
* must be "insert" or "delete".
*
* If is "insert", then each of the key-value pairs in
* the map in is added to only if its key is not
* already present. 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 "delete", then may have the same type
* as (a map type), or it may be a set whose element type
* is the same as 's key type:
*
* + If is a map, the mutation deletes each key-value
* pair in whose key and value equal one of the key-
* value pairs in .
*
* + If is a set, the mutation deletes each key-value
* pair in whose key equals one of the values in
* .
*
* For "delete", may have any number of elements,
* regardless of restrictions on the number of elements in
* .
* }
*
*/
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
public class Mutation {
private final String column;
private final Mutator mutator;
private final Value value;
/**
* Create a {@link Mutation} object.
*
* @param column value of the "column" field
* @param mutator value of the "mutator" field
* @param value value of the "value" field
*/
public Mutation(String column, Mutator mutator, Value value) {
this.column = column;
this.mutator = mutator;
this.value = value;
}
public String getColumn() {
return column;
}
public Mutator getMutator() {
return mutator;
}
public Value getValue() {
return value;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Mutation)) {
return false;
}
Mutation mutation = (Mutation) other;
return Objects.equals(column, mutation.getColumn())
&& mutator == mutation.getMutator()
&& Objects.equals(value, mutation.getValue());
}
@Override
public int hashCode() {
return Objects.hash(column, mutator, value);
}
@Override
public String toString() {
return getClass().getSimpleName() + " ["
+ "column=" + column
+ ", mutator=" + mutator
+ ", value=" + value
+ "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy