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;
10 import java.util.HashMap;
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.message.PCCreateMessageValidator;
16 import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageValidator;
17 import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageValidator;
18 import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageValidator;
19 import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageValidator;
20 import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageValidator;
21 import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageValidator;
22 import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageValidator;
23 import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageValidator;
24 import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageValidator;
25 import org.opendaylight.protocol.pcep.spi.PCEPMessageType;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
29 * Base class for message validators
31 public abstract class PCEPMessageValidator {
33 private static class MapOfValidators extends HashMap<PCEPMessageType, PCEPMessageValidator> {
35 private static final long serialVersionUID = -5715193806554448822L;
37 private final static MapOfValidators instance = new MapOfValidators();
39 private MapOfValidators() {
43 private void fillInMap() {
44 this.put(PCEPMessageType.OPEN, new PCEPOpenMessageValidator());
45 this.put(PCEPMessageType.KEEPALIVE, new PCEPKeepAliveMessageValidator());
46 this.put(PCEPMessageType.NOTIFICATION, new PCEPNotificationMessageValidator());
47 this.put(PCEPMessageType.ERROR, new PCEPErrorMessageValidator());
48 this.put(PCEPMessageType.RESPONSE, new PCEPReplyMessageValidator());
49 this.put(PCEPMessageType.REQUEST, new PCEPRequestMessageValidator());
50 this.put(PCEPMessageType.UPDATE_REQUEST, new PCEPUpdateRequestMessageValidator());
51 this.put(PCEPMessageType.STATUS_REPORT, new PCEPReportMessageValidator());
52 this.put(PCEPMessageType.CLOSE, new PCEPCloseMessageValidator());
53 this.put(PCEPMessageType.PCCREATE, new PCCreateMessageValidator());
56 public static MapOfValidators getInstance() {
61 public abstract List<Message> validate(List<PCEPObject> objects) throws PCEPDeserializerException;
63 public static PCEPMessageValidator getValidator(final PCEPMessageType msgType) {
64 return MapOfValidators.getInstance().get(msgType);