2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.pcep.impl.message;
10 import java.util.ArrayList;
11 import java.util.List;
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.protocol.pcep.message.PCEPOpenMessage;
17 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
21 * PCEPOpenMessage validator. Validates message integrity.
23 public class PCEPOpenMessageValidator extends PCEPMessageValidator {
26 public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
28 throw new IllegalArgumentException("Passed list can't be null.");
30 if (objects.isEmpty() || !(objects.get(0) instanceof PCEPOpenObject))
31 throw new PCEPDeserializerException("Open message doesn't contain OPEN object.");
33 final PCEPOpenMessage msg = new PCEPOpenMessage((PCEPOpenObject) objects.get(0));
36 if (!objects.isEmpty())
37 throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
39 return new ArrayList<Message>() {
40 private static final long serialVersionUID = 1L;