2 * Copyright (c) 2017 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.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
10 import static java.util.Objects.requireNonNull;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
15 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
16 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
17 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;
23 public class MatchTablePropertySerializer extends AbstractTablePropertySerializer<Match> implements
24 SerializerRegistryInjector {
26 private SerializerRegistry registry;
29 protected void serializeProperty(final Match property, final ByteBuf byteBuf) {
32 .nonnullSetFieldMatch().values()
33 .forEach(setFieldMatch -> requireNonNull(registry)
34 .<MatchField, OFSerializer<SetFieldMatch>>getSerializer(new MessageTypeKey<>(
35 EncodeConstants.OF_VERSION_1_3, setFieldMatch.getMatchType().implementedInterface()))
36 .serialize(setFieldMatch, byteBuf));
40 protected TableFeaturesPropType getType() {
41 return TableFeaturesPropType.OFPTFPTMATCH;
45 protected Class<Match> getClazz() {
50 public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) {
51 registry = serializerRegistry;