blob: 18b63ac204ec645990bc3faae7fdc1c70d2851ed [file] [log] [blame]
Deepa vaddireddy386f38b2017-08-02 06:24:01 +00001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16package org.opencord.sadis.impl;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
19import org.onosproject.codec.CodecContext;
20import org.onosproject.codec.JsonCodec;
21import org.opencord.sadis.SubscriberAndDeviceInformation;
22
23public class SubscriberAndDeviceInformationCodec extends JsonCodec<SubscriberAndDeviceInformation> {
24 @Override
25 public ObjectNode encode(SubscriberAndDeviceInformation entry, CodecContext context) {
26 final ObjectNode result = context.mapper().createObjectNode()
27 .put("id", entry.id())
28 .put("cTag", (entry.cTag() == null) ? "" : entry.cTag().toString())
29 .put("sTag", (entry.sTag() == null) ? "" : entry.sTag().toString())
30 .put("nasPortId", entry.nasPortId())
31 .put("port", entry.port())
32 .put("slot", entry.slot())
33 .put("hardwareIdentifier", (entry.hardwareIdentifier() == null) ? "" :
34 entry.hardwareIdentifier().toString())
35 .put("ipAddress", (entry.ipAddress() == null) ? "" : entry.ipAddress().toString())
36 .put("nasId", entry.nasId());
37 return result;
38 }
39}