2 * Copyright © 2014, 2017 Matt Oswalt and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.ovsdb.lib.operations;
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.opendaylight.ovsdb.lib.notation.Condition;
14 import org.opendaylight.ovsdb.lib.notation.Mutation;
15 import org.opendaylight.ovsdb.lib.notation.Mutator;
16 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
17 import org.opendaylight.ovsdb.lib.schema.TableSchema;
19 public class Mutate<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
21 public static final String MUTATE = "mutate";
22 List<Condition> where = new ArrayList<>();
23 private List<Mutation> mutations = new ArrayList<>();
25 public Mutate on(TableSchema schema) {
26 this.setTableSchema(schema);
30 public Mutate(TableSchema<E> schema) {
31 super(schema, MUTATE);
34 @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") // validate call below
35 public <T extends TableSchema<T>, D> Mutate<E> addMutation(ColumnSchema<T, D> columnSchema,
36 Mutator mutator, D value) {
37 columnSchema.validate(value);
38 Object untypedValue = columnSchema.getNormalizeData(value);
39 mutations.add(new Mutation(columnSchema.getName(), mutator, untypedValue));
43 public List<Mutation> getMutations() {
47 public void setMutations(List<Mutation> mutations) {
48 this.mutations = mutations;
52 public void addCondition(Condition condition) {
53 this.where.add(condition);
56 public Where where(Condition condition) {
57 this.where.add(condition);
58 return new Where(this);
61 public List<Condition> getWhere() {
65 public void setWhere(List<Condition> where) {