2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.openflowjava.protocol.impl.util;
10 import static java.util.Objects.requireNonNull;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
14 import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
16 import org.opendaylight.yangtools.yang.common.Uint8;
19 * Helper class for registering instruction serializers.
21 * @author michal.polkorab
23 public class InstructionSerializerRegistryHelper {
25 private final Uint8 version;
26 private final SerializerRegistry serializerRegistry;
31 * @param version Openflow wire version
32 * @param serializerRegistry registry to be filled with message serializers
34 public InstructionSerializerRegistryHelper(final Uint8 version, final SerializerRegistry serializerRegistry) {
35 this.version = requireNonNull(version);
36 this.serializerRegistry = serializerRegistry;
40 * Registers given serializer.
42 * @param instructionType instruction type
43 * @param serializer serializer instance
45 public <T extends InstructionChoice> void registerSerializer(final Class<T> instructionType,
46 final OFGeneralSerializer serializer) {
47 serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, instructionType, null),