Migrate to use unit types and cleanup builder usage.
Change-Id: Id9e8199d7c1fcccfa653bd1ad4c3b740fd9566f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.in.port.type.grouping.NxmOfInPortValuesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfInPortCaseValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfInPortCaseValueBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
public class InPortCodec extends AbstractMatchCodec {
NXM_FIELD_CODE);
@Override
- public void serialize(MatchEntry input, ByteBuf outBuffer) {
+ public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
serializeHeader(input, outBuffer);
OfInPortCaseValue value = (OfInPortCaseValue) input.getMatchEntryValue();
outBuffer.writeInt(value.getNxmOfInPortValues().getValue().toJava());
}
@Override
- public MatchEntry deserialize(ByteBuf message) {
+ public MatchEntry deserialize(final ByteBuf message) {
return deserializeHeaderToBuilder(message)
.setMatchEntryValue(new OfInPortCaseValueBuilder()
- .setNxmOfInPortValues(new NxmOfInPortValuesBuilder().setValue(message.readInt()).build())
+ .setNxmOfInPortValues(new NxmOfInPortValuesBuilder()
+ .setValue(Uint16.valueOf(message.readInt()))
+ .build())
.build())
.build();
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfMplsLabel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.oxm.of.mpls.label.grouping.MplsLabelValuesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfMplsLabelCaseValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfMplsLabelCaseValueBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class MplsLabelCodec extends AbstractMatchCodec {
EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
@Override
- public void serialize(MatchEntry input, ByteBuf outBuffer) {
+ public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
serializeHeader(input, outBuffer);
- OfMplsLabelCaseValue value = (OfMplsLabelCaseValue) input.getMatchEntryValue();
- outBuffer.writeInt(value.getMplsLabelValues().getMplsLabel().intValue());
+ outBuffer.writeInt(((OfMplsLabelCaseValue) input.getMatchEntryValue()).getMplsLabelValues().getMplsLabel()
+ .intValue());
}
@Override
- public MatchEntry deserialize(ByteBuf message) {
- MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
- OfMplsLabelCaseValueBuilder caseBuilder = new OfMplsLabelCaseValueBuilder();
- MplsLabelValuesBuilder valuesBuilder = new MplsLabelValuesBuilder();
- valuesBuilder.setMplsLabel(message.readLong()).build();
- caseBuilder.setMplsLabelValues(valuesBuilder.build());
- matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
- return matchEntryBuilder.build();
+ public MatchEntry deserialize(final ByteBuf message) {
+ return deserializeHeaderToBuilder(message)
+ .setMatchEntryValue(new OfMplsLabelCaseValueBuilder()
+ .setMplsLabelValues(new MplsLabelValuesBuilder()
+ .setMplsLabel(Uint32.valueOf(message.readLong()))
+ .build())
+ .build())
+ .build();
}
@Override
*/
package org.opendaylight.openflowjava.nx.codec.match;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.openflowjava.nx.api.NiciraConstants;
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshTtl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.ttl.grouping.NshTtlValues;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nsh.ttl.grouping.NshTtlValuesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshTtlCaseValue;
private static final int VALUE_LENGTH = Byte.BYTES;
private static final int NXM_FIELD_CODE = 10;
public static final MatchEntrySerializerKey<ExperimenterClass, NxmNxNshTtl> SERIALIZER_KEY =
- createSerializerKey(
- EncodeConstants.OF13_VERSION_ID,
- NiciraConstants.NX_NSH_VENDOR_ID,
- NxmNxNshTtl.class);
+ createSerializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_NSH_VENDOR_ID, NxmNxNshTtl.class);
public static final MatchEntryDeserializerKey DESERIALIZER_KEY =
- createDeserializerKey(
- EncodeConstants.OF13_VERSION_ID,
- NiciraConstants.NX_NSH_VENDOR_ID,
- NXM_FIELD_CODE);
+ createDeserializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_NSH_VENDOR_ID, NXM_FIELD_CODE);
@Override
- protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
- NshTtlCaseValue nshTtlCaseValue = (NshTtlCaseValue) value;
- NshTtlValues nshTtlValues = nshTtlCaseValue.getNshTtlValues();
+ protected void serializeValue(final NxExpMatchEntryValue value, final boolean hasMask, final ByteBuf outBuffer) {
+ final var nshTtlValues = ((NshTtlCaseValue) value).getNshTtlValues();
outBuffer.writeByte(nshTtlValues.getNshTtl().toJava());
if (hasMask) {
outBuffer.writeByte(nshTtlValues.getMask().toJava());
}
@Override
- protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
- Short ttlValue = message.readUnsignedByte();
- Short maskValue = hasMask ? message.readUnsignedByte() : null;
- NshTtlValues nshTtlValues = new NshTtlValuesBuilder().setNshTtl(ttlValue).setMask(maskValue).build();
- return new NshTtlCaseValueBuilder().setNshTtlValues(nshTtlValues).build();
+ protected NxExpMatchEntryValue deserializeValue(final ByteBuf message, final boolean hasMask) {
+ return new NshTtlCaseValueBuilder()
+ .setNshTtlValues(new NshTtlValuesBuilder()
+ .setNshTtl(readUint8(message))
+ .setMask(hasMask ? readUint8(message) : null)
+ .build())
+ .build();
}
@Override
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.id.grouping.TunIdValuesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIdCaseValue;
EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE);
@Override
- public void serialize(MatchEntry input, ByteBuf outBuffer) {
+ public void serialize(final MatchEntry input, final ByteBuf outBuffer) {
serializeHeader(input, outBuffer);
outBuffer.writeLong(((TunIdCaseValue) input.getMatchEntryValue()).getTunIdValues().getValue().longValue());
}
@Override
- public MatchEntry deserialize(ByteBuf message) {
- MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message);
- TunIdCaseValueBuilder caseBuilder = new TunIdCaseValueBuilder();
- TunIdValuesBuilder tunIdBuilder = new TunIdValuesBuilder();
- tunIdBuilder.setValue(BigInteger.valueOf(message.readLong()));
- caseBuilder.setTunIdValues(tunIdBuilder.build());
- matchEntriesBuilder.setMatchEntryValue(caseBuilder.build());
- return matchEntriesBuilder.build();
+ public MatchEntry deserialize(final ByteBuf message) {
+ return deserializeHeaderToBuilder(message)
+ .setMatchEntryValue(new TunIdCaseValueBuilder()
+ .setTunIdValues(new TunIdValuesBuilder().setValue(BigInteger.valueOf(message.readLong())).build())
+ .build())
+ .build();
}
@Override