01: /*
02: * Copyright 2007 Hippo.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */
16: package nl.hippo.cms.brokenlinkchecker.util;
17:
18: /**
19: * <p>
20: * A utility class to help with validation.
21: * </p>
22: */
23: public class Validation {
24: /**
25: * <p>
26: * The only and private constructor to prevent instantiation of this
27: * class.
28: * </p>
29: */
30: public Validation() {
31: super ();
32: }
33:
34: /**
35: * <p>
36: * Check if a predicate was true. If not add an error message to the
37: * full error message.
38: * </p>
39: *
40: * @param predicateResult
41: * the result of the predicate.
42: * @param validationErrorMessage
43: * the full error message to which to append the error
44: * message if the predicate result is <code>false</code>.
45: * @param predicateErrorMessage
46: * the error message to append if the predicate result is
47: * <code>false</code>.
48: * @return <code>true</code> if the predicate was true,
49: * <code>false</code> otherwise.
50: */
51: public static boolean assertTrue(boolean predicateResult,
52: StringBuffer validationErrorMessage,
53: String predicateErrorMessage) {
54: boolean result = predicateResult;
55:
56: if (!result) {
57: validationErrorMessage.append(predicateErrorMessage);
58: validationErrorMessage.append(' ');
59: }
60:
61: return result;
62: }
63: }
|