import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp;
/**
- * Parser for {@link PcntfMessage}
+ * Parser for {@link PcntfMessage}.
*/
public class PCEPNotificationMessageParser extends AbstractMessageParser {
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
- Preconditions.checkArgument(message instanceof PcntfMessage, "Wrong instance of Message. Passed instance of %s. Need PcntfMessage.", message.getClass());
+ Preconditions.checkArgument(message instanceof PcntfMessage,
+ "Wrong instance of Message. Passed instance of %s. Need PcntfMessage.", message.getClass());
final ByteBuf buffer = Unpooled.buffer();
for (final Notifications n : ((PcntfMessage) message).getPcntfMessage().getNotifications()) {
if (n.getRps() != null) {
serializeObject(rps.getRp(), buffer);
}
}
- Preconditions.checkArgument(n.getNotifications() != null && !n.getNotifications().isEmpty(), "Message must contain at least one notification object");
- for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications not : n.getNotifications()) {
+ Preconditions.checkArgument(n.getNotifications() != null && !n.getNotifications().isEmpty(),
+ "Message must contain at least one notification object");
+ for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.Notifications not : n.getNotifications()) {
serializeObject(not.getCNotification(), buffer);
}
}
}
@Override
- protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
+ protected Message validate(final List<Object> objects, final List<Message> errors)
+ throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Notification message cannot be empty.");
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
- return new PcntfBuilder().setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
+ return new PcntfBuilder()
+ .setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
}
private static Notifications getValidNotificationComposite(final List<Object> objects, final List<Message> errors) {
final List<Rps> requestParameters = new ArrayList<>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications> notifications = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.Notifications> notifications = new ArrayList<>();
Object obj;
State state = State.INIT;
return null;
}
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.NotificationsBuilder().setNotifications(
- notifications).setRps(requestParameters).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.NotificationsBuilder().setNotifications(notifications)
+ .setRps(requestParameters).build();
}
- private static State insertObject(final State state, final Object obj, final List<Message> errors, final List<Rps> requestParameters, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications> notifications) {
+ private static State insertObject(final State state, final Object obj, final List<Message> errors,
+ final List<Rps> requestParameters,
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.Notifications> notifications) {
switch (state) {
case INIT:
if (obj instanceof Rp) {
requestParameters.add(new RpsBuilder().setRp(rp).build());
return State.INIT;
}
- // fall-through
+ // fallthrough
case RP_IN:
if (obj instanceof CNotification) {
final CNotification n = (CNotification) obj;
notifications.add(new NotificationsBuilder().setCNotification(n).build());
return State.RP_IN;
}
- // fall-through
+ // fallthrough
case NOTIFICATION_IN:
- // fall-through
case END:
return State.END;
default: