Brian O'Connor | 562d9d3 | 2016-10-07 12:16:50 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Brian O'Connor | 562d9d3 | 2016-10-07 12:16:50 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.store.serializers; |
| 17 | |
| 18 | import com.esotericsoftware.kryo.Kryo; |
| 19 | import com.esotericsoftware.kryo.Serializer; |
| 20 | import com.esotericsoftware.kryo.io.Input; |
| 21 | import com.esotericsoftware.kryo.io.Output; |
| 22 | import org.onosproject.net.ConnectPoint; |
| 23 | import org.onosproject.net.FilteredConnectPoint; |
| 24 | import org.onosproject.net.flow.TrafficSelector; |
| 25 | |
| 26 | /** |
| 27 | * Kryo Serializer for {@link FilteredConnectPointSerializer}. |
| 28 | */ |
| 29 | public 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 | } |