Committed by
Gerrit Code Review
[ONOS-2545]Add the deserialization of UUID.
When converting the operation result of insert into POJO, it need the deserialization of UUID. Change-Id: I04f30dd044ddc0963d3f59bda62a9fc469e55e1e
Showing
3 changed files
with
37 additions
and
6 deletions
| ... | @@ -22,9 +22,7 @@ import java.util.List; | ... | @@ -22,9 +22,7 @@ import java.util.List; |
| 22 | import org.onosproject.ovsdb.rfc.notation.Row; | 22 | import org.onosproject.ovsdb.rfc.notation.Row; |
| 23 | import org.onosproject.ovsdb.rfc.notation.UUID; | 23 | import org.onosproject.ovsdb.rfc.notation.UUID; |
| 24 | 24 | ||
| 25 | -import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 26 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 25 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 27 | -import com.fasterxml.jackson.annotation.JsonProperty; | ||
| 28 | 26 | ||
| 29 | /** | 27 | /** |
| 30 | * All results of ovs table operations. refer to RFC7047 5.2. | 28 | * All results of ovs table operations. refer to RFC7047 5.2. |
| ... | @@ -32,7 +30,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; | ... | @@ -32,7 +30,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; |
| 32 | @JsonIgnoreProperties(ignoreUnknown = true) | 30 | @JsonIgnoreProperties(ignoreUnknown = true) |
| 33 | public final class OperationResult { | 31 | public final class OperationResult { |
| 34 | private int count; | 32 | private int count; |
| 35 | - @JsonIgnore | ||
| 36 | private UUID uuid; | 33 | private UUID uuid; |
| 37 | private List<Row> rows; | 34 | private List<Row> rows; |
| 38 | private String error; | 35 | private String error; |
| ... | @@ -95,7 +92,6 @@ public final class OperationResult { | ... | @@ -95,7 +92,6 @@ public final class OperationResult { |
| 95 | * Return uuid. | 92 | * Return uuid. |
| 96 | * @return uuid | 93 | * @return uuid |
| 97 | */ | 94 | */ |
| 98 | - @JsonProperty("uuid") | ||
| 99 | public UUID getUuid() { | 95 | public UUID getUuid() { |
| 100 | return uuid; | 96 | return uuid; |
| 101 | } | 97 | } |
| ... | @@ -104,9 +100,9 @@ public final class OperationResult { | ... | @@ -104,9 +100,9 @@ public final class OperationResult { |
| 104 | * Set uuid value. | 100 | * Set uuid value. |
| 105 | * @param uuid the Operation message of uuid | 101 | * @param uuid the Operation message of uuid |
| 106 | */ | 102 | */ |
| 107 | - public void setUuid(String uuid) { | 103 | + public void setUuid(UUID uuid) { |
| 108 | checkNotNull(uuid, "uuid cannot be null"); | 104 | checkNotNull(uuid, "uuid cannot be null"); |
| 109 | - this.uuid = UUID.uuid(uuid); | 105 | + this.uuid = uuid; |
| 110 | } | 106 | } |
| 111 | 107 | ||
| 112 | /** | 108 | /** | ... | ... |
| ... | @@ -20,14 +20,17 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -20,14 +20,17 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 20 | 20 | ||
| 21 | import java.util.Objects; | 21 | import java.util.Objects; |
| 22 | 22 | ||
| 23 | +import org.onosproject.ovsdb.rfc.notation.json.UUIDConverter; | ||
| 23 | import org.onosproject.ovsdb.rfc.notation.json.UUIDSerializer; | 24 | import org.onosproject.ovsdb.rfc.notation.json.UUIDSerializer; |
| 24 | 25 | ||
| 26 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
| 25 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; | 27 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| 26 | 28 | ||
| 27 | /** | 29 | /** |
| 28 | * Handles both uuid and named-uuid. | 30 | * Handles both uuid and named-uuid. |
| 29 | */ | 31 | */ |
| 30 | @JsonSerialize(using = UUIDSerializer.class) | 32 | @JsonSerialize(using = UUIDSerializer.class) |
| 33 | +@JsonDeserialize(converter = UUIDConverter.class) | ||
| 31 | public final class UUID { | 34 | public final class UUID { |
| 32 | private final String value; | 35 | private final String value; |
| 33 | 36 | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.ovsdb.rfc.notation.json; | ||
| 17 | + | ||
| 18 | +import org.onosproject.ovsdb.rfc.notation.UUID; | ||
| 19 | + | ||
| 20 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 21 | +import com.fasterxml.jackson.databind.util.StdConverter; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * UUIDConverter Converter. | ||
| 25 | + */ | ||
| 26 | +public class UUIDConverter extends StdConverter<JsonNode, UUID> { | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public UUID convert(JsonNode json) { | ||
| 30 | + return UUID.uuid(json.get(1).asText()); | ||
| 31 | + } | ||
| 32 | +} |
-
Please register or login to post a comment