*/
package org.opendaylight.protocol.rsvp.parser.impl.subobject.ero;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectParser;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
/**
* Parser for { PathKey }.
*/
-public class EROPathKey128SubobjectParser extends CommonPathKeyParser implements EROSubobjectParser {
-
+public class EROPathKey128SubobjectParser implements EROSubobjectParser {
public static final int TYPE = 65;
protected static final int PCE128_ID_F_LENGTH = 16;
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(),
- "Array of bytes is mandatory. Can't be null or empty.");
+ checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT128_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
+ "Expected: >" + CONTENT128_LENGTH + ".");
}
- final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
- builder.setLoose(loose);
- builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(parsePathKey(PCE128_ID_F_LENGTH, buffer)).build());
- return builder.build();
+ return new SubobjectContainerBuilder()
+ .setLoose(loose)
+ .setSubobjectType(new PathKeyCaseBuilder().setPathKey(parsePathKey(PCE128_ID_F_LENGTH, buffer)).build())
+ .build();
}
}
*/
package org.opendaylight.protocol.rsvp.parser.impl.subobject.ero;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.serializePathKey;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectParser;
import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectSerializer;
import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectUtil;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
/**
* Parser for {PathKey}.
*/
-public class EROPathKey32SubobjectParser extends CommonPathKeyParser implements EROSubobjectParser,
- EROSubobjectSerializer {
-
+public class EROPathKey32SubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
public static final int TYPE = 64;
private static final int PCE_ID_F_LENGTH = 4;
-
private static final int CONTENT_LENGTH = 2 + PCE_ID_F_LENGTH;
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(),
- "Array of bytes is mandatory. Can't be null or empty.");
+ checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
+ "Expected: >" + CONTENT_LENGTH + ".");
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
- Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
- "Unknown subobject instance.Passed %s. Needed PathKey.",
- subobject.getSubobjectType().getClass());
+ checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+ "Unknown subobject instance.Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType())
.getPathKey();
*/
package org.opendaylight.protocol.rsvp.parser.impl.subobject.ero;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface;
+
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectSerializer;
import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectUtil;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonUnnumberedInterfaceSubobjectParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder;
/**
* Parser for {@link UnnumberedCase}.
*/
-public class EROUnnumberedInterfaceSubobjectParser extends CommonUnnumberedInterfaceSubobjectParser implements
- EROSubobjectParser, EROSubobjectSerializer {
-
+public class EROUnnumberedInterfaceSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
public static final int TYPE = 4;
private static final int RESERVED = 2;
-
private static final int CONTENT_LENGTH = 10;
@Override
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.rsvp.parser.impl.subobject.xro;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
/**
* Parser for { PathKey}.
*/
-public class XROPathKey128SubobjectParser extends CommonPathKeyParser implements XROSubobjectParser {
+public class XROPathKey128SubobjectParser implements XROSubobjectParser {
public static final int TYPE = 65;
protected static final int PCE128_ID_F_LENGTH = 16;
private static final int CONTENT128_LENGTH = 2 + PCE128_ID_F_LENGTH;
@Override
- public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
- RSVPParsingException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory)
+ throws RSVPParsingException {
+ checkArgument(buffer != null && buffer.isReadable(),
"Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT128_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.rsvp.parser.impl.subobject.xro;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.serializePathKey;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectSerializer;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
/**
* Parser for { PathKey}.
*/
-public class XROPathKey32SubobjectParser extends CommonPathKeyParser implements XROSubobjectParser,
- XROSubobjectSerializer {
+public class XROPathKey32SubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
public static final int TYPE = 64;
private static final int PCE_ID_F_LENGTH = 4;
-
private static final int CONTENT_LENGTH = 2 + PCE_ID_F_LENGTH;
@Override
- public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
- RSVPParsingException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory)
+ throws RSVPParsingException {
+ checkArgument(buffer != null && buffer.isReadable(),
"Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
- Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
- "Unknown subobject instance.Passed %s. Needed PathKey.",
- subobject.getSubobjectType().getClass());
+ checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+ "Unknown subobject instance.Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType())
.getPathKey();
package org.opendaylight.protocol.rsvp.parser.impl.subobject.xro;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectSerializer;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
/**
* Parser for {@link UnnumberedCase}.
*/
-public class XROUnnumberedInterfaceSubobjectParser extends CommonUnnumberedInterfaceSubobjectParser
- implements XROSubobjectParser, XROSubobjectSerializer {
+public class XROUnnumberedInterfaceSubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
public static final int TYPE = 4;
private static final int RESERVED = 1;
buffer.readerIndex(buffer.readerIndex() + RESERVED);
return new SubobjectContainerBuilder()
.setMandatory(mandatory)
- .setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()))
+ .setAttribute(Attribute.forValue(buffer.readUnsignedByte()))
.setSubobjectType(parseUnnumeredInterface(buffer))
.build();
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
-public class CommonPathKeyParser {
- protected CommonPathKeyParser() {
-
+public final class PathKeyUtils {
+ private PathKeyUtils() {
+ // Hidden on purpose
}
public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
-public class CommonUnnumberedInterfaceSubobjectParser {
- protected CommonUnnumberedInterfaceSubobjectParser() {
-
+public final class UnnumberedInterfaceSubobjectUtils {
+ private UnnumberedInterfaceSubobjectUtils() {
+ // Hidden on purpose
}
- protected static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
+ public static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
return new UnnumberedCaseBuilder()
.setUnnumbered(new UnnumberedBuilder()
.setRouterId(ByteBufUtils.readUint32(buffer))
.build();
}
- protected static void serializeUnnumeredInterface(final Unnumbered unnumbered, final ByteBuf body) {
+ public static void serializeUnnumeredInterface(final Unnumbered unnumbered, final ByteBuf body) {
ByteBufUtils.writeMandatory(body, unnumbered.getRouterId(), "RouterId");
ByteBufUtils.writeMandatory(body, unnumbered.getInterfaceId(), "InterfaceId");
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
import org.opendaylight.yangtools.yang.common.Uint16;
-public class CommonPathKeyParserTest {
- private final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5};
+public class PathKeyUtilsTest {
+ private final byte[] bytes = new byte[] { 0, 1, 2, 3, 4, 5 };
private PathKey key1;
private PathKey key2;
private PathKey key3;
@Test(expected = IllegalArgumentException.class)
public void testSerializationExcption1() {
- CommonPathKeyParser.serializePathKey(this.key1);
+ PathKeyUtils.serializePathKey(this.key1);
}
@Test(expected = IllegalArgumentException.class)
public void testSerializationExcption2() {
- CommonPathKeyParser.serializePathKey(this.key2);
+ PathKeyUtils.serializePathKey(this.key2);
}
@Test
public void testSerialization() {
- final ByteBuf output = CommonPathKeyParser.serializePathKey(this.key3);
+ final ByteBuf output = PathKeyUtils.serializePathKey(this.key3);
assertArrayEquals(this.bytes, ByteArray.readAllBytes(output));
}
@Test
public void testParsing() {
- assertEquals(this.key3, CommonPathKeyParser.parsePathKey(4, Unpooled.copiedBuffer(this.bytes)));
+ assertEquals(this.key3, PathKeyUtils.parsePathKey(4, Unpooled.copiedBuffer(this.bytes)));
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
import org.opendaylight.yangtools.yang.common.Uint32;
-public class CUISubobjectParserTest {
+public class UnnumberedInterfaceSubobjectUtilsTest {
private final Uint32 routerId = Uint32.valueOf(3735928559L);
private final Uint32 interfaceId = Uint32.valueOf(3736059631L);
private final Unnumbered unnumbered1 = new UnnumberedBuilder().setRouterId((Uint32) null).build();
final ByteBuf input = Unpooled.buffer(8);
input.writeInt(this.routerId.intValue());
input.writeInt(this.interfaceId.intValue());
- final UnnumberedCase output = CommonUnnumberedInterfaceSubobjectParser.parseUnnumeredInterface(input);
+ final UnnumberedCase output = UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface(input);
assertEquals(this.routerId, output.getUnnumbered().getRouterId());
assertEquals(this.interfaceId, output.getUnnumbered().getInterfaceId());
final ByteBuf bytebuf = Unpooled.buffer(8);
- CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(output.getUnnumbered(), bytebuf);
+ UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(output.getUnnumbered(), bytebuf);
assertArrayEquals(input.array(), bytebuf.array());
}
@Test(expected = IllegalArgumentException.class)
public void testException1() {
- CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(this.unnumbered1, Unpooled.EMPTY_BUFFER);
+ UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(this.unnumbered1, Unpooled.EMPTY_BUFFER);
}
@Test(expected = IllegalArgumentException.class)
public void testException2() {
- CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(this.unnumbered2, Unpooled.buffer(4));
+ UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(this.unnumbered2, Unpooled.buffer(4));
}
-
}