blob: a23fa69feded17b529a286d53358b293ce612263 [file] [log] [blame]
Harshada Chaundkar9204f312019-07-02 16:01:24 +00001/*
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
17package org.onosproject.segmentrouting.mcast;
18
19
20import com.esotericsoftware.kryo.Kryo;
21import com.esotericsoftware.kryo.Serializer;
22import com.esotericsoftware.kryo.io.Input;
23import com.esotericsoftware.kryo.io.Output;
24import org.onlab.packet.VlanId;
25import org.onosproject.net.ConnectPoint;
26
27/**
28 * Custom serializer for {@link McastFilteringObjStoreKey}.
29 */
30class 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}