Update MRI projects for Aluminium
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / multipart / tablefeatures / ApplyActionsTablePropertySerializer.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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
9 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.tablefeatures;
10
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action;
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.table.feature.prop.type.table.feature.prop.type.ApplyActions;
20
21 public class ApplyActionsTablePropertySerializer extends AbstractTablePropertySerializer<ApplyActions> implements
22         SerializerRegistryInjector {
23
24     private SerializerRegistry registry;
25
26     @Override
27     protected void serializeProperty(final ApplyActions property, final ByteBuf byteBuf) {
28         property
29                 .getApplyActions()
30                 .nonnullAction()
31                 .values()
32                 .stream()
33                 .sorted(OrderComparator.build())
34                 .map(Action::getAction)
35                 .forEach(action -> ActionUtil
36                         .writeActionHeader(
37                                 action,
38                                 EncodeConstants.OF13_VERSION_ID,
39                                 registry,
40                                 byteBuf));
41     }
42
43     @Override
44     protected TableFeaturesPropType getType() {
45         return TableFeaturesPropType.OFPTFPTAPPLYACTIONS;
46     }
47
48     @Override
49     protected Class<ApplyActions> getClazz() {
50         return ApplyActions.class;
51     }
52
53     @Override
54     public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) {
55         registry = serializerRegistry;
56     }
57
58 }