490d27c10df2c2288786571367c45623d2b89c0f
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / validation / checks / ConnConstraintCheck.java
1 /*
2  * Copyright © 2018 Orange, 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.transportpce.tapi.validation.checks;
9
10 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
11 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ServiceType;
12 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.ConnectivityConstraint;
13
14 public final class ConnConstraintCheck {
15
16     private ConnConstraintCheck() {
17     }
18
19     public static boolean checkString(String value) {
20         return ((value != null) && (value.compareTo("") != 0));
21     }
22
23     public static ComplianceCheckResult check(ConnectivityConstraint cc) {
24         boolean result = true;
25         String message = "";
26
27         if (!cc.getServiceType().equals(ServiceType.POINTTOPOINTCONNECTIVITY)) {
28             result = false;
29             message = "Service-Type is not Point-to-Point";
30         } else if (!checkString(cc.getServiceLevel())) {
31             result = false;
32             message = "Service-Level is not set";
33         }
34
35         return new ComplianceCheckResult(result, message);
36     }
37 }