use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessage in project bgpcep by opendaylight.
the class PCEPCloseMessageParser method validate.
@Override
protected Close validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty() || !(objects.get(0) instanceof CClose)) {
throw new PCEPDeserializerException("Close message doesn't contain CLOSE object.");
}
final Object o = objects.get(0);
final CCloseMessage msg = new CCloseMessageBuilder().setCClose((CClose) o).build();
objects.remove(0);
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new CloseBuilder().setCCloseMessage(msg).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessage in project bgpcep by opendaylight.
the class PCEPCloseMessageParser method validate.
@Override
protected Close validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final Object o = objects.poll();
if (!(o instanceof CClose)) {
throw new PCEPDeserializerException("Close message doesn't contain CLOSE object.");
}
final CCloseMessage msg = new CCloseMessageBuilder().setCClose((CClose) o).build();
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new CloseBuilder().setCCloseMessage(msg).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessage in project bgpcep by opendaylight.
the class PCEPCloseMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
checkArgument(message instanceof CloseMessage, "Wrong instance of Message. Passed instance of %s. Need CloseMessage.", message.getClass());
final CCloseMessage close = ((CloseMessage) message).getCCloseMessage();
checkArgument(close.getCClose() != null, "Close Object must be present in Close Message.");
final ByteBuf buffer = Unpooled.buffer();
serializeObject(close.getCClose(), buffer);
MessageUtil.formatMessage(TYPE, buffer, out);
}
Aggregations