org.opendaylight.ovsdb.lib.message.TableUpdate Maven / Gradle / Ivy
/*
* Copyright © 2014, 2017 EBay Software Foundation and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.ovsdb.lib.message;
import java.util.HashMap;
import java.util.Map;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
public class TableUpdate> {
private final Map> rows = new HashMap<>();
public Map> getRows() {
return rows;
}
public static final class RowUpdate> {
private final UUID uuid;
private final Row oldRow;
private final Row newRow;
public RowUpdate(final UUID uuid, final Row oldRow, final Row newRow) {
this.uuid = uuid;
this.oldRow = oldRow;
this.newRow = newRow;
}
public UUID getUuid() {
return this.uuid;
}
public Row getOld() {
return oldRow;
}
public Row getNew() {
return newRow;
}
@Override
public String toString() {
return "RowUpdate [uuid=" + uuid + ", oldRow=" + oldRow + ", newRow=" + newRow + "]";
}
}
public void addRow(final UUID uuid, final Row oldRow, final Row newRow) {
rows.put(uuid, new RowUpdate<>(uuid, oldRow, newRow));
}
public Row getOld(final UUID uuid) {
RowUpdate rowUpdate = rows.get(uuid);
return rowUpdate != null ? rowUpdate.getOld() : null;
}
public Row getNew(final UUID uuid) {
RowUpdate rowUpdate = rows.get(uuid);
return rowUpdate != null ? rowUpdate.getNew() : null;
}
@Override
public String toString() {
return "TableUpdate [" + rows + "]";
}
}