clean some compilation warnings
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / PceComplianceCheck.java
1 /*
2  * Copyright © 2017 AT&T 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.pce;
9
10 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13
14 /*
15  * Class to check RPCs Compliancy.
16  */
17 public final class PceComplianceCheck {
18
19     private static final Logger LOG = LoggerFactory.getLogger(PceComplianceCheck.class);
20
21     /*
22      * Check if a String is not
23      * null and not equal to ''.
24      *
25      * @param value String value
26      * @return  true  if String ok
27      *          false if not
28      */
29     public static boolean checkString(String value) {
30         return (value != null) && (value.compareTo("") != 0);
31     }
32
33     public static PceComplianceCheckResult check(PathComputationRequestInput input) {
34         String message = "";
35         Boolean result = true;
36         if (input != null) {
37             if (!checkString(input.getServiceName())) {
38                 result = false;
39                 message = "Service Name is not set";
40                 LOG.debug(message);
41             } else {
42                 if (!checkString(input.getServiceHandlerHeader().getRequestId())) {
43                     result = false;
44                     message = "ServiceHandlerHeader Request-ID  is not set";
45                     LOG.debug(message);
46                 }
47             }
48         } else {
49             result = false;
50         }
51         return new PceComplianceCheckResult(result, message);
52     }
53
54     private PceComplianceCheck() {
55     }
56
57 }
58