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
9 package org.opendaylight.openflowplugin.impl.protocol.serialization.multipart;
11 import com.google.common.base.MoreObjects;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
14 import org.opendaylight.openflowplugin.api.OFConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
18 public class MultipartRequestMeterStatsSerializer implements OFSerializer<MultipartRequestMeterStats> {
20 private static final byte PADDING_IN_MULTIPART_REQUEST_METER_BODY = 4;
23 public void serialize(final MultipartRequestMeterStats multipartRequestMeterStats, final ByteBuf byteBuf) {
24 byteBuf.writeInt(MoreObjects
25 .firstNonNull(multipartRequestMeterStats.getStatMeterId(), new MeterId(OFConstants.OFPM_ALL))
26 .getValue().intValue());
27 byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_METER_BODY);