001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.util.tester; 018 019/** 020 * A <code>Result</code> class. 021 * 022 * @author unknown 023 * @since 1.2.6 024 */ 025public class Result 026{ 027 public static final Result PASS = new Result(false); 028 029 private final boolean failed; 030 private final String message; 031 032 public Result(boolean failed) 033 { 034 this(failed, ""); 035 } 036 037 public Result(boolean failed, String message) 038 { 039 this.failed = failed; 040 this.message = message; 041 } 042 043 /** 044 * Returns a <code>Result</code> which failed. 045 * 046 * @param message 047 * an error message 048 * @return a <code>Result</code> which failed 049 */ 050 public static Result fail(String message) 051 { 052 return new Result(true, message); 053 } 054 055 /** 056 * Returns a <code>Result</code> which passed. 057 * 058 * @return a <code>Result</code> which passed 059 */ 060 public static Result pass() 061 { 062 return PASS; 063 } 064 065 /** 066 * Returns <code>true</code> if the <code>Result</code> was a failure. 067 * 068 * @return <code>true</code> if the <code>Result</code> was a failure 069 */ 070 public boolean wasFailed() 071 { 072 return failed; 073 } 074 075 /** 076 * Retrieves the error message. 077 * 078 * @return the error message 079 */ 080 public String getMessage() 081 { 082 return message; 083 } 084}