blob: 74195837e2380fd27f7a7f9130b4ed8c30e5dcdd [file] [log] [blame]
jaegonkime0f45b52018-10-09 20:23:26 +09001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.workflow.api;
17
18
19/**
20 * Static convenience class that help a whether it was invoked correctly(whether its preconditions have been met).
21 * Methods of this class generally accept a boolean expression which is expected to be true.
22 * When false (or null) is passed instead, the Preconditions method throws an workflow exception.
23 */
24public final class CheckCondition {
25
26 /**
27 * Private class of check condition.
28 */
29 private CheckCondition() {
30 }
31
32 /**
33 * Checks the condition, and if it is false, it raises workflow exception with exception message.
34 * @param condition condition to check. A boolean expression is located on here.
35 * @param exceptionMessage exception message for workflow exception
36 * @throws WorkflowException workflow exception
37 */
38 public static void check(boolean condition, String exceptionMessage) throws WorkflowException {
39 if (!condition) {
40 throw new WorkflowException(exceptionMessage);
41 }
42 }
43
44}