Harshada Chaundkar | 9204f31 | 2019-07-02 16:01:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | |
| 17 | package org.onosproject.segmentrouting.mcast; |
| 18 | |
| 19 | |
| 20 | import com.esotericsoftware.kryo.Kryo; |
| 21 | import com.esotericsoftware.kryo.Serializer; |
| 22 | import com.esotericsoftware.kryo.io.Input; |
| 23 | import com.esotericsoftware.kryo.io.Output; |
| 24 | import org.onlab.packet.VlanId; |
| 25 | import org.onosproject.net.ConnectPoint; |
| 26 | |
| 27 | /** |
| 28 | * Custom serializer for {@link McastFilteringObjStoreKey}. |
| 29 | */ |
| 30 | class McastFilteringObjStoreSerializer extends Serializer<McastFilteringObjStoreKey> { |
| 31 | |
| 32 | /** |
| 33 | * Creates {@link McastFilteringObjStoreSerializer} serializer instance. |
| 34 | */ |
| 35 | McastFilteringObjStoreSerializer() { |
| 36 | // non-null, immutable |
| 37 | super(false, true); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public void write(Kryo kryo, Output output, McastFilteringObjStoreKey object) { |
| 42 | kryo.writeClassAndObject(output, object.ingressCP()); |
| 43 | kryo.writeClassAndObject(output, object.vlanId()); |
| 44 | kryo.writeClassAndObject(output, object.isIpv4()); |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public McastFilteringObjStoreKey read(Kryo kryo, Input input, Class<McastFilteringObjStoreKey> type) { |
| 49 | ConnectPoint ingressCP = (ConnectPoint) kryo.readClassAndObject(input); |
| 50 | VlanId vlanId = (VlanId) kryo.readClassAndObject(input); |
| 51 | boolean isIpv4 = (boolean) kryo.readClassAndObject(input); |
| 52 | return new McastFilteringObjStoreKey(ingressCP, vlanId, isIpv4); |
| 53 | } |
| 54 | } |