blob: 4ef0194dd0618d7682c720bc1e2cee53926555f2 [file] [log] [blame]
pier9e02ab72020-02-12 20:40:55 +01001/*
2 * Copyright 2020-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.IpAddress;
25import org.onosproject.net.ConnectPoint;
26
27/**
28 * Custom serializer for {@link McastPathStoreKey}.
29 */
30class McastPathStoreKeySerializer extends Serializer<McastPathStoreKey> {
31
32 /**
33 * Creates {@link McastPathStoreKeySerializer} serializer instance.
34 */
35 McastPathStoreKeySerializer() {
36 // non-null, immutable
37 super(false, true);
38 }
39
40 @Override
41 public void write(Kryo kryo, Output output, McastPathStoreKey object) {
42 kryo.writeClassAndObject(output, object.mcastIp());
43 kryo.writeClassAndObject(output, object.source());
44 }
45
46 @Override
47 public McastPathStoreKey read(Kryo kryo, Input input, Class<McastPathStoreKey> type) {
48 IpAddress mcastIp = (IpAddress) kryo.readClassAndObject(input);
49 ConnectPoint source = (ConnectPoint) kryo.readClassAndObject(input);
50 return new McastPathStoreKey(mcastIp, source);
51 }
52}