blob: 8563f2a03009a7163b6881a17d8710320de995a4 [file] [log] [blame]
Jian Lif2acb662017-04-06 02:06:16 +09001/*
2 * Copyright 2017-present Open Networking Laboratory
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.onosproject.drivers.lisp.extensions.codec;
17
18import com.fasterxml.jackson.databind.ObjectMapper;
19import org.onosproject.codec.CodecContext;
20import org.onosproject.codec.CodecService;
21import org.onosproject.codec.JsonCodec;
22
23/**
24 * An adapter that provides LISP mapping extension codec context.
25 */
26public class LispMappingExtensionCodecContextAdapter implements CodecContext {
27
28 private final ObjectMapper mapper = new ObjectMapper();
29 private final CodecService manager;
30
31 /**
32 * Constructs a new mock codec context.
33 *
34 * @param manager codec manager
35 */
36 public LispMappingExtensionCodecContextAdapter(CodecService manager) {
37 this.manager = manager;
38 }
39
40 @Override
41 public ObjectMapper mapper() {
42 return mapper;
43 }
44
45 @Override
46 public <T> JsonCodec<T> codec(Class<T> entityClass) {
47 return manager.getCodec(entityClass);
48 }
49
50 @Override
51 public <T> T getService(Class<T> serviceClass) {
52 return null;
53 }
54}