lishuai
Committed by Thomas Vachuska

[ONOS-2499]update accordingly for ONOS-2408's review recommendation

Change-Id: I24e7c4acbe38e4286b994c5bf50d22def945fb29
Showing 31 changed files with 81 additions and 69 deletions
......@@ -42,9 +42,9 @@ public final class MonitorRequest {
*/
public MonitorRequest(String tableName, Set<String> columns,
MonitorSelect select) {
checkNotNull(tableName, "tableName is not null");
checkNotNull(columns, "columns is not null");
checkNotNull(select, "select is not null");
checkNotNull(tableName, "table name cannot be null");
checkNotNull(columns, "columns cannot be null");
checkNotNull(select, "select cannot be null");
this.tableName = tableName;
this.columns = columns;
this.select = select;
......
......@@ -50,7 +50,7 @@ public final class OperationResult {
* @param rows List of Row entity
*/
public OperationResult(List<Row> rows) {
checkNotNull(rows, "rows is not null");
checkNotNull(rows, "rows cannot be null");
this.rows = rows;
}
......@@ -64,10 +64,10 @@ public final class OperationResult {
*/
public OperationResult(int count, UUID uuid, List<Row> rows, String error,
String details) {
checkNotNull(uuid, "uuid is not null");
checkNotNull(rows, "rows is not null");
checkNotNull(error, "error is not null");
checkNotNull(details, "details is not null");
checkNotNull(uuid, "uuid cannot be null");
checkNotNull(rows, "rows cannot be null");
checkNotNull(error, "error cannot be null");
checkNotNull(details, "details cannot be null");
this.count = count;
this.uuid = uuid;
this.rows = rows;
......@@ -105,7 +105,7 @@ public final class OperationResult {
* @param uuid the Operation message of uuid
*/
public void setUuid(String uuid) {
checkNotNull(uuid, "uuid is not null");
checkNotNull(uuid, "uuid cannot be null");
this.uuid = UUID.uuid(uuid);
}
......@@ -122,7 +122,7 @@ public final class OperationResult {
* @param rows the Operation message of rows
*/
public void setRows(List<Row> rows) {
checkNotNull(rows, "rows is not null");
checkNotNull(rows, "rows cannot be null");
this.rows = rows;
}
......@@ -139,7 +139,7 @@ public final class OperationResult {
* @param error the Operation message of error
*/
public void setError(String error) {
checkNotNull(error, "error is not null");
checkNotNull(error, "error cannot be null");
this.error = error;
}
......@@ -156,7 +156,7 @@ public final class OperationResult {
* @param details the Operation message of details
*/
public void setDetails(String details) {
checkNotNull(details, "details is not null");
checkNotNull(details, "details cannot be null");
this.details = details;
}
}
......
......@@ -40,7 +40,7 @@ public final class RowUpdate {
* @param newRow present for "initial", "insert", and "modify" updates
*/
public RowUpdate(UUID uuid, Row oldRow, Row newRow) {
checkNotNull(uuid, "uuid is not null");
checkNotNull(uuid, "uuid cannot be null");
this.uuid = uuid;
this.oldRow = oldRow;
this.newRow = newRow;
......
......@@ -16,6 +16,7 @@
package org.onosproject.ovsdb.rfc.message;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import java.util.Objects;
......@@ -44,6 +45,7 @@ public final class TableUpdate {
* @return TableUpdate entity
*/
public static TableUpdate tableUpdate(Map<UUID, RowUpdate> rows) {
checkNotNull(rows, "rows cannot be null");
return new TableUpdate(rows);
}
......
......@@ -44,7 +44,7 @@ public final class TableUpdates {
* @return TableUpdates
*/
public static TableUpdates tableUpdates(Map<String, TableUpdate> result) {
checkNotNull(result, "result is not null");
checkNotNull(result, "result cannot be null");
return new TableUpdates(result);
}
......
......@@ -41,8 +41,8 @@ public final class UpdateNotification {
* @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode
*/
public UpdateNotification(Object context, JsonNode tbUpdatesJsonNode) {
checkNotNull(context, "context is not null");
checkNotNull(tbUpdatesJsonNode, "tbUpdatesJsonNode is not null");
checkNotNull(context, "context cannot be null");
checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null");
this.context = context;
this.tbUpdatesJsonNode = tbUpdatesJsonNode;
}
......
......@@ -38,8 +38,8 @@ public final class Column {
* @param obj the data of the column
*/
public Column(ColumnSchema schema, Object obj) {
checkNotNull(schema, "schema is not null");
checkNotNull(obj, "data is not null");
checkNotNull(schema, "schema cannot be null");
checkNotNull(obj, "data cannot be null");
this.schema = schema;
this.data = obj;
}
......
......@@ -64,9 +64,9 @@ public final class Condition {
* @param value column data
*/
public Condition(String column, Function function, Object value) {
checkNotNull(column, "column is not null");
checkNotNull(function, "function is not null");
checkNotNull(value, "value is not null");
checkNotNull(column, "column cannot be null");
checkNotNull(function, "function cannot be null");
checkNotNull(value, "value cannot be null");
this.column = column;
this.function = function;
this.value = value;
......
......@@ -65,9 +65,9 @@ public final class Mutation {
* @param value column data
*/
public Mutation(String column, Mutator mutator, Object value) {
checkNotNull(column, "column is not null");
checkNotNull(mutator, "mutator is not null");
checkNotNull(value, "value is not null");
checkNotNull(column, "column cannot be null");
checkNotNull(mutator, "mutator cannot be null");
checkNotNull(value, "value cannot be null");
this.column = column;
this.mutator = mutator;
this.value = value;
......
......@@ -38,7 +38,7 @@ public final class OvsdbMap {
* @param map java.util.Map
*/
private OvsdbMap(Map map) {
checkNotNull(map, "map is not null");
checkNotNull(map, "map cannot be null");
this.map = map;
}
......
......@@ -40,7 +40,7 @@ public final class OvsdbSet {
* @param set java.util.Set
*/
private OvsdbSet(Set set) {
checkNotNull(set, "set is not null");
checkNotNull(set, "set cannot be null");
this.set = set;
}
......
......@@ -36,8 +36,8 @@ public final class RefTableRow {
* @param jsonNode JsonNode
*/
public RefTableRow(String refTable, JsonNode jsonNode) {
checkNotNull(refTable, "refTable is not null");
checkNotNull(jsonNode, "jsonNode is not null");
checkNotNull(refTable, "refTable cannot be null");
checkNotNull(jsonNode, "jsonNode cannot be null");
this.refTable = refTable;
this.jsonNode = jsonNode;
}
......
......@@ -49,7 +49,7 @@ public final class Row {
* @param tableSchema TableSchema entity
*/
public Row(TableSchema tableSchema) {
checkNotNull(tableSchema, "tableSchema is not null");
checkNotNull(tableSchema, "tableSchema cannot be null");
this.tableSchema = tableSchema;
this.columns = Maps.newHashMap();
}
......@@ -60,8 +60,8 @@ public final class Row {
* @param columns List of Column entity
*/
public Row(TableSchema tableSchema, List<Column> columns) {
checkNotNull(tableSchema, "tableSchema is not null");
checkNotNull(columns, "columns is not null");
checkNotNull(tableSchema, "tableSchema cannot be null");
checkNotNull(columns, "columns cannot be null");
this.tableSchema = tableSchema;
this.columns = Maps.newHashMap();
for (Column column : columns) {
......
......@@ -36,7 +36,7 @@ public final class UUID {
* @param value UUID value
*/
private UUID(String value) {
checkNotNull(value, "value is not null");
checkNotNull(value, "value cannot be null");
this.value = value;
}
......
......@@ -20,7 +20,6 @@ import java.io.IOException;
import org.onosproject.ovsdb.rfc.notation.UUID;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
......@@ -30,13 +29,12 @@ import com.fasterxml.jackson.databind.SerializerProvider;
public class UUIDSerializer extends JsonSerializer<UUID> {
@Override
public void serialize(UUID value, JsonGenerator generator,
SerializerProvider provider)
throws IOException, JsonProcessingException {
SerializerProvider provider) throws IOException {
generator.writeStartArray();
try {
java.util.UUID.fromString(value.value());
String reg = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
if (value.value().matches(reg)) {
generator.writeString("uuid");
} catch (IllegalArgumentException ex) {
} else {
generator.writeString("named-uuid");
}
generator.writeString(value.value());
......
......@@ -32,7 +32,7 @@ public final class Assert implements Operation {
* @param lock the lock member of assert operation
*/
public Assert(String lock) {
checkNotNull(lock, "lock is not null");
checkNotNull(lock, "lock cannot be null");
this.op = Operations.ASSERT.op();
this.lock = lock;
}
......
......@@ -32,7 +32,7 @@ public final class Comment implements Operation {
* @param comment the comment member of comment operation
*/
public Comment(String comment) {
checkNotNull(comment, "comment is not null");
checkNotNull(comment, "comment cannot be null");
this.op = Operations.COMMENT.op();
this.comment = comment;
}
......
......@@ -32,7 +32,7 @@ public final class Commit implements Operation {
* @param durable the durable member of commit operation
*/
public Commit(Boolean durable) {
checkNotNull(durable, "durable is not null");
checkNotNull(durable, "durable cannot be null");
this.op = Operations.COMMIT.op();
this.durable = durable;
}
......
......@@ -41,7 +41,7 @@ public final class Delete implements Operation {
* @param where the List of Condition entity
*/
public Delete(TableSchema schema, List<Condition> where) {
checkNotNull(schema, "TableSchema is not null");
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(where, "where is not null");
this.tableSchema = schema;
this.op = Operations.DELETE.op();
......
......@@ -49,9 +49,9 @@ public final class Insert implements Operation {
* @param row Row entity
*/
public Insert(TableSchema schema, String uuidName, Row row) {
checkNotNull(schema, "TableSchema is not null");
checkNotNull(uuidName, "uuidName is not null");
checkNotNull(row, "row is not null");
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(uuidName, "uuid name cannot be null");
checkNotNull(row, "row cannot be null");
this.tableSchema = schema;
this.op = Operations.INSERT.op();
this.uuidName = uuidName;
......
......@@ -45,9 +45,9 @@ public final class Mutate implements Operation {
*/
public Mutate(TableSchema schema, List<Condition> where,
List<Mutation> mutations) {
checkNotNull(schema, "TableSchema is not null");
checkNotNull(mutations, "mutations is not null");
checkNotNull(where, "where is not null");
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(mutations, "mutations cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.MUTATE.op();
this.where = where;
......
......@@ -43,9 +43,9 @@ public final class Select implements Operation {
* @param columns the List of column name
*/
public Select(TableSchema schema, List<Condition> where, List<String> columns) {
checkNotNull(schema, "TableSchema is not null");
checkNotNull(where, "where is not null");
checkNotNull(columns, "columns is not null");
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(where, "where cannot be null");
checkNotNull(columns, "columns cannot be null");
this.tableSchema = schema;
this.op = Operations.SELECT.op();
this.where = where;
......
......@@ -50,9 +50,9 @@ public final class Update implements Operation {
* @param where the List of Condition entity
*/
public Update(TableSchema schema, Row row, List<Condition> where) {
checkNotNull(schema, "TableSchema is not null");
checkNotNull(row, "row is not null");
checkNotNull(where, "where is not null");
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(row, "row cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.UPDATE.op();
this.row = Maps.newHashMap();
......
......@@ -35,8 +35,8 @@ public final class ColumnSchema {
* @param columnType the column type
*/
public ColumnSchema(String name, ColumnType columnType) {
checkNotNull(name, "name is not null");
checkNotNull(columnType, "columnType is not null");
checkNotNull(name, "name cannot be null");
checkNotNull(columnType, "column type cannot be null");
this.name = name;
this.type = columnType;
}
......
......@@ -40,9 +40,9 @@ public final class DatabaseSchema {
*/
public DatabaseSchema(String name, String version,
Map<String, TableSchema> tableSchemas) {
checkNotNull(name, "name is not null");
checkNotNull(version, "version is not null");
checkNotNull(tableSchemas, "tableSchemas is not null");
checkNotNull(name, "name cannot be null");
checkNotNull(version, "version cannot be null");
checkNotNull(tableSchemas, "tableSchemas cannot be null");
this.name = name;
this.version = version;
this.tableSchemas = tableSchemas;
......
......@@ -40,8 +40,8 @@ public final class TableSchema {
* @param columnSchemas a map of ColumnSchema
*/
public TableSchema(String name, Map<String, ColumnSchema> columnSchemas) {
checkNotNull(name, "name is not null");
checkNotNull(columnSchemas, "columnSchemas is not null");
checkNotNull(name, "name cannot be null");
checkNotNull(columnSchemas, "columnSchemas cannot be null");
this.name = name;
this.columnSchemas = columnSchemas;
}
......
......@@ -34,7 +34,7 @@ public final class AtomicColumnType implements ColumnType {
* @param baseType BaseType entity
*/
public AtomicColumnType(BaseType baseType) {
checkNotNull(baseType, "BaseType is not null");
checkNotNull(baseType, "BaseType cannot be null");
this.baseType = baseType;
this.min = 1;
this.max = 1;
......@@ -47,7 +47,7 @@ public final class AtomicColumnType implements ColumnType {
* @param max max constraint
*/
public AtomicColumnType(BaseType baseType, int min, int max) {
checkNotNull(baseType, "BaseType is not null");
checkNotNull(baseType, "BaseType cannot be null");
this.baseType = baseType;
this.min = min;
this.max = max;
......
......@@ -39,8 +39,8 @@ public final class KeyValuedColumnType implements ColumnType {
*/
public KeyValuedColumnType(BaseType keyType, BaseType valueType, int min,
int max) {
checkNotNull(keyType, "keyType is not null");
checkNotNull(valueType, "valueType is not null");
checkNotNull(keyType, "keyType cannot be null");
checkNotNull(valueType, "valueType cannot be null");
this.keyType = keyType;
this.valueType = valueType;
this.min = min;
......
......@@ -16,6 +16,7 @@
package org.onosproject.ovsdb.rfc.schema.type;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
......@@ -62,6 +63,7 @@ public final class UuidBaseType implements BaseType {
* @param refType refType constraint
*/
public UuidBaseType(String refTable, String refType) {
checkNotNull(refType, "refType cannot be null");
this.refTable = refTable;
this.refType = refType;
}
......
......@@ -33,7 +33,7 @@ public final class ObjectMapperUtil {
/**
* Constructs a ObjectMapperUtil object. Utility classes should not have a
* public or default constructor, otherwise it will compile failed. This
* public or default constructor, otherwise IDE will compile unsuccessfully. This
* class should not be instantiated.
*/
private ObjectMapperUtil() {
......
......@@ -43,7 +43,7 @@ public final class TransValueUtil {
/**
* Constructs a TransValueUtil object. Utility classes should not have a
* public or default constructor, otherwise it will compile failed.
* public or default constructor, otherwise IDE will compile unsuccessfully.
* This class should not be instantiated.
*/
private TransValueUtil() {
......@@ -81,7 +81,12 @@ public final class TransValueUtil {
return null;
}
// Convert AtomicColumnType JsonNode into OvsdbSet value
/**
* Convert AtomicColumnType JsonNode into OvsdbSet value.
* @param json AtomicColumnType JsonNode
* @param atoType AtomicColumnType entity
* @return Object OvsdbSet or the value of JsonNode
*/
private static Object getValueFromAtoType(JsonNode json,
AtomicColumnType atoType) {
BaseType baseType = atoType.baseType();
......@@ -112,7 +117,12 @@ public final class TransValueUtil {
}
}
// Convert KeyValuedColumnType JsonNode into OvsdbMap value
/**
* Convert KeyValuedColumnType JsonNode into OvsdbMap value.
* @param json KeyValuedColumnType JsonNode
* @param kvType KeyValuedColumnType entity
* @return Object OvsdbMap
*/
private static Object getValueFromKvType(JsonNode json,
KeyValuedColumnType kvType) {
if (json.isArray()) {
......