c9830e2fc151a79ce6e0bb4b0b2d9f580372cab8
[openflowplugin.git] / extension / openflowjava-extension-eric / src / main / java / org / opendaylight / openflowjava / eric / EricExtensionsRegistrator.java
1 /*
2  * Copyright (c) 2019 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowjava.eric;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.openflowjava.eric.api.EricExtensionCodecRegistrator;
12 import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDOptionsTypeCodec;
13 import org.opendaylight.openflowjava.eric.codec.match.Icmpv6NDReservedCodec;
14
15 public class EricExtensionsRegistrator implements AutoCloseable {
16     private final EricExtensionCodecRegistrator registrator;
17
18     public EricExtensionsRegistrator(EricExtensionCodecRegistrator registrator) {
19         this.registrator = Preconditions.checkNotNull(registrator);
20         registrator.registerMatchEntrySerializer(Icmpv6NDReservedCodec.SERIALIZER_KEY,
21                 Icmpv6NDReservedCodec.INSTANCE);
22         registrator.registerMatchEntrySerializer(Icmpv6NDOptionsTypeCodec.SERIALIZER_KEY,
23                 Icmpv6NDOptionsTypeCodec.INSTANCE);
24         registrator.registerMatchEntryDeserializer(Icmpv6NDReservedCodec.DESERIALIZER_KEY,
25                 Icmpv6NDReservedCodec.INSTANCE);
26         registrator.registerMatchEntryDeserializer(Icmpv6NDOptionsTypeCodec.DESERIALIZER_KEY,
27                 Icmpv6NDOptionsTypeCodec.INSTANCE);
28     }
29
30     @Override
31     public void close()  {
32         registrator.unregisterMatchEntrySerializer(Icmpv6NDReservedCodec.SERIALIZER_KEY);
33         registrator.unregisterMatchEntrySerializer(Icmpv6NDOptionsTypeCodec.SERIALIZER_KEY);
34         registrator.unregisterMatchEntryDeserializer(Icmpv6NDReservedCodec.DESERIALIZER_KEY);
35         registrator.unregisterMatchEntryDeserializer(Icmpv6NDOptionsTypeCodec.DESERIALIZER_KEY);
36     }
37 }