blob: 40c2891a1ad6a9e5b37ad6b1dca2fef4ff8a1787 [file] [log] [blame]
Jian Lifa69be62017-04-05 16:00:10 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jian Lifa69be62017-04-05 16:00:10 +09003 *
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 */
Jian Li2e818b02017-04-12 19:28:30 +090016package org.onosproject.mapping.codec;
Jian Lifa69be62017-04-05 16:00:10 +090017
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 mapping codec context.
25 */
26public class MappingCodecContextAdapter 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 MappingCodecContextAdapter(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}