2 * Copyright (C) 2014 EBay Software Foundation
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 * Authors : Ashwin Raveendran
10 package org.opendaylight.ovsdb.lib.operations;
15 import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
16 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
17 import org.opendaylight.ovsdb.lib.schema.TableSchema;
19 import com.fasterxml.jackson.annotation.JsonProperty;
20 import com.google.common.base.Preconditions;
21 import com.google.common.collect.Maps;
24 public class Insert<E extends TableSchema<E>> extends Operation<E> {
26 public static final String INSERT = "insert";
30 @JsonProperty("uuid-name")
31 private String uuidName;
33 private Map<String, Object> row = Maps.newHashMap();
35 public Insert<E> on(TableSchema schema){
36 this.setTableSchema(schema);
40 public Insert<E> withId(String name) {
47 public Insert(TableSchema<E> schema) {
48 super(schema, INSERT);
51 public <D, C extends TableSchema<C>> Insert<E> value(ColumnSchema<C, D> columnSchema, D value) {
52 Object untypedValue = null;
53 if (columnSchema.getType().isMultiValued()) {
54 Preconditions.checkArgument((value instanceof Set),"expected a set for multivalued item") ;
55 untypedValue = OvsDBSet.fromSet((Set) value);
59 row.put(columnSchema.getName(), untypedValue);
63 public String getUuid() {
67 public void setUuid(String uuid) {
71 public String getUuidName() {
75 public void setUuidName(String uuidName) {
76 this.uuidName = uuidName;
79 public Map<String, Object> getRow() {
83 public void setRow(Map<String, Object> row) {