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.PCEPMessage;
15 import org.opendaylight.protocol.pcep.PCEPObject;
16 import org.opendaylight.protocol.pcep.impl.PCEPMessageFactory.PCEPMessageType;
17 import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageValidator;
18 import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageValidator;
19 import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageValidator;
20 import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageValidator;
21 import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageValidator;
22 import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageValidator;
23 import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageValidator;
24 import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageValidator;
25 import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageValidator;
26 import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageValidator;
27 import org.opendaylight.protocol.pcep.impl.message.PCEPXRAddTunnelMessageValidator;
28 import org.opendaylight.protocol.pcep.impl.message.PCEPXRDeleteTunnelMessageValidator;
31 * Base class for message validators
33 public abstract class PCEPMessageValidator {
35 private static class MapOfValidators extends HashMap<PCEPMessageType, PCEPMessageValidator> {
37 private static final long serialVersionUID = -5715193806554448822L;
39 private final static MapOfValidators instance = new MapOfValidators();
41 private MapOfValidators() {
45 private void fillInMap() {
46 this.put(PCEPMessageType.OPEN, new PCEPOpenMessageValidator());
47 this.put(PCEPMessageType.KEEPALIVE, new PCEPKeepAliveMessageValidator());
48 this.put(PCEPMessageType.NOTIFICATION, new PCEPNotificationMessageValidator());
49 this.put(PCEPMessageType.ERROR, new PCEPErrorMessageValidator());
50 this.put(PCEPMessageType.RESPONSE, new PCEPReplyMessageValidator());
51 this.put(PCEPMessageType.REQUEST, new PCEPRequestMessageValidator());
52 this.put(PCEPMessageType.UPDATE_REQUEST, new PCEPUpdateRequestMessageValidator());
53 this.put(PCEPMessageType.STATUS_REPORT, new PCEPReportMessageValidator());
54 this.put(PCEPMessageType.CLOSE, new PCEPCloseMessageValidator());
55 this.put(PCEPMessageType.XR_ADD_TUNNEL, new PCEPXRAddTunnelMessageValidator());
56 this.put(PCEPMessageType.XR_DELETE_TUNNEL, new PCEPXRDeleteTunnelMessageValidator());
57 this.put(PCEPMessageType.PCCREATE, new PCCreateMessageValidator());
60 public static MapOfValidators getInstance() {
65 public abstract List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException;
67 public static PCEPMessageValidator getValidator(final PCEPMessageType msgType) {
68 return MapOfValidators.getInstance().get(msgType);