blob: e5dd02b4345c2c56bb18294218fa480b12fe7f41 [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())
Amit Ghoshd5d60cf2017-11-09 11:00:09 +000031 .put("uplinkPort", entry.uplinkPort())
Deepa vaddireddy386f38b2017-08-02 06:24:01 +000032 .put("slot", entry.slot())
33 .put("hardwareIdentifier", (entry.hardwareIdentifier() == null) ? "" :
34 entry.hardwareIdentifier().toString())
35 .put("ipAddress", (entry.ipAddress() == null) ? "" : entry.ipAddress().toString())
David K. Bainbridge8bf98e02017-08-07 10:41:56 -070036 .put("nasId", entry.nasId())
37 .put("circuiltId", (entry.circuitId() == null) ? "" : entry.circuitId())
38 .put("remoteId", (entry.remoteId() == null) ? "" : entry.remoteId());
39
Deepa vaddireddy386f38b2017-08-02 06:24:01 +000040 return result;
41 }
42}