2 * Copyright 2015 Open Networking Laboratory
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 package org.onosproject.vtnrsc.web;
\r
18 import static com.google.common.base.Preconditions.checkNotNull;
\r
20 import org.onosproject.codec.CodecContext;
\r
21 import org.onosproject.codec.JsonCodec;
\r
22 import org.onosproject.vtnrsc.AllowedAddressPair;
\r
24 import com.fasterxml.jackson.databind.node.ObjectNode;
\r
27 * VirtualPort AllowedAddressPair codec.
\r
29 public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
\r
32 public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
\r
33 checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
\r
34 ObjectNode result = context.mapper().createObjectNode()
\r
35 .put("ip_address", alocAddPair.ip().toString())
\r
36 .put("mac_address", alocAddPair.mac().toString());
\r