blob: 169d819827d5c80571f82490629927c61e296f0a [file] [log] [blame]
Jian Liee65a232017-03-29 14:15:30 +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.mapping.web.codec;
17
18import com.fasterxml.jackson.databind.node.ObjectNode;
19import org.onosproject.codec.CodecContext;
20import org.onosproject.codec.JsonCodec;
21import org.onosproject.mapping.actions.MappingAction;
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24
25/**
26 * Mapping action codec.
27 */
28public final class MappingActionCodec extends JsonCodec<MappingAction> {
29
30 protected static final Logger log =
31 LoggerFactory.getLogger(MappingActionCodec.class);
32
33 protected static final String TYPE = "type";
34 protected static final String ERROR_MESSAGE =
35 " not specified in MappingAction";
36
37 @Override
38 public ObjectNode encode(MappingAction action, CodecContext context) {
39 EncodeMappingActionCodecHelper encoder =
40 new EncodeMappingActionCodecHelper(action, context);
41 return encoder.encode();
42 }
43
44 @Override
45 public MappingAction decode(ObjectNode json, CodecContext context) {
46 DecodeMappingActionCodecHelper decoder =
47 new DecodeMappingActionCodecHelper(json);
48 return decoder.decode();
49 }
50}