Merge "Randomize port to allow concurrent execution"
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / message / PCEPKeepAliveMessageValidator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.impl.message;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
14 import org.opendaylight.protocol.pcep.PCEPObject;
15 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder;
19
20 /**
21  * PCEPKeepAliveMessage validator. Validates message integrity.
22  */
23 public class PCEPKeepAliveMessageValidator extends PCEPMessageValidator {
24
25         @Override
26         public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
27                 if (objects != null && !objects.isEmpty())
28                         throw new PCEPDeserializerException("KeepAlive message has content.");
29
30                 return new ArrayList<Message>() {
31                         private static final long serialVersionUID = 1L;
32
33                         {
34                                 this.add(new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build());
35                         }
36                 };
37         }
38 }