use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method parseObject.
@Override
public Svec parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (bytes.readableBytes() < MIN_SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
}
bytes.skipBytes(FLAGS_F_OFFSET);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
final List<RequestId> requestIDs = new ArrayList<>();
while (bytes.isReadable()) {
requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
}
if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
}
return new SvecBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setLinkDiverse(flags.get(L_FLAG_OFFSET)).setNodeDiverse(flags.get(N_FLAG_OFFSET)).setSrlgDiverse(flags.get(S_FLAG_OFFSET)).setLinkDirectionDiverse(flags.get(D_FLAG_OFFSET)).setPartialPathDiverse(flags.get(P_FLAG_OFFSET)).setRequestsIds(requestIDs).build();
}
Aggregations