blob: 8bd38f145ac09ecdec14322bb66e95f9eda65565 [file] [log] [blame]
Gamze Abaka1e5ccf52018-07-02 11:59:03 +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.BandwidthProfileInformation;
22
23public class BandwidthProfileCodec extends JsonCodec<BandwidthProfileInformation> {
24 @Override
25 public ObjectNode encode(BandwidthProfileInformation entry, CodecContext context) {
26 return context.mapper().createObjectNode()
27 .put("id", entry.id())
28 .put("cir", (entry.committedInformationRate()))
29 .put("cbs", (entry.committedBurstSize() == null) ? "" : entry.committedBurstSize().toString())
30 .put("eir", entry.exceededInformationRate())
31 .put("ebs", (entry.exceededBurstSize() == null) ? "" : entry.exceededBurstSize().toString())
32 .put("air", entry.assuredInformationRate());
33 }
34
35}