Deepa vaddireddy | 386f38b | 2017-08-02 06:24:01 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.opencord.sadis.impl; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 19 | import org.onosproject.codec.CodecContext; |
| 20 | import org.onosproject.codec.JsonCodec; |
| 21 | import org.opencord.sadis.SubscriberAndDeviceInformation; |
| 22 | |
| 23 | public 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 Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 31 | .put("uplinkPort", entry.uplinkPort()) |
Deepa vaddireddy | 386f38b | 2017-08-02 06:24:01 +0000 | [diff] [blame] | 32 | .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. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 36 | .put("nasId", entry.nasId()) |
| 37 | .put("circuiltId", (entry.circuitId() == null) ? "" : entry.circuitId()) |
| 38 | .put("remoteId", (entry.remoteId() == null) ? "" : entry.remoteId()); |
| 39 | |
Deepa vaddireddy | 386f38b | 2017-08-02 06:24:01 +0000 | [diff] [blame] | 40 | return result; |
| 41 | } |
| 42 | } |