blob: 84511e1485468f3ab40022b8510d76c851b81456 [file] [log] [blame]
Brian O'Connor562d9d32016-10-07 12:16:50 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Brian O'Connor562d9d32016-10-07 12:16:50 -07003 *
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.store.serializers;
17
18import com.esotericsoftware.kryo.Kryo;
19import com.esotericsoftware.kryo.Serializer;
20import com.esotericsoftware.kryo.io.Input;
21import com.esotericsoftware.kryo.io.Output;
22import org.onosproject.net.ConnectPoint;
23import org.onosproject.net.FilteredConnectPoint;
24import org.onosproject.net.flow.TrafficSelector;
25
26/**
27 * Kryo Serializer for {@link FilteredConnectPointSerializer}.
28 */
29public class FilteredConnectPointSerializer extends Serializer<FilteredConnectPoint> {
30
31 /**
32 * Creates {@link FilteredConnectPointSerializer} serializer instance.
33 */
34 public FilteredConnectPointSerializer() {
35 // non-null, immutable
36 super(false, true);
37 }
38
39 @Override
40 public void write(Kryo kryo, Output output, FilteredConnectPoint object) {
41 kryo.writeClassAndObject(output, object.connectPoint());
42 kryo.writeClassAndObject(output, object.trafficSelector());
43 }
44
45 @Override
46 public FilteredConnectPoint read(Kryo kryo, Input input, Class<FilteredConnectPoint> type) {
47 ConnectPoint connectPoint = (ConnectPoint) kryo.readClassAndObject(input);
48 TrafficSelector trafficSelector = (TrafficSelector) kryo.readClassAndObject(input);
49 return new FilteredConnectPoint(connectPoint, trafficSelector);
50 }
51}