d962a08a287b729d74e00e80a537d9f4e4f3e630
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / ccaps / ConnectionValidator.java
1 /*
2  * Copyright (c) 2015 CableLabs 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
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.ccaps;
10
11 import org.opendaylight.controller.packetcable.provider.validation.impl.validators.AbstractValidator;
12 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161128.ccap.attributes.Connection;
13
14 /**
15  * @author rvail
16  */
17 public class ConnectionValidator extends AbstractValidator<Connection> {
18
19     private static final String IP_ADDRESS = "connection.ipAddress";
20     private static final String PORT = "connection.port";
21
22     @Override
23     protected void doValidate(final Connection connection, Extent extent) {
24         if (connection == null) {
25            getErrorMessages().add("connection must exist");
26             return;
27         }
28
29         mustExist(connection.getIpAddress(), IP_ADDRESS);
30
31         // Note PortNumber validates range on creation so only existence needs to be checked
32         mustExist(connection.getPort(), PORT);
33     }
34 }