1 /* 2 * $Id$ 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 package org.apache.struts.validator.validwhen; 22 23 /** 24 * Holds the (interim) result during processing the parsing-tree. 25 * 26 * @author Graff Stefan 27 * 28 * @param <T> the current type of the result 29 * 30 * @since Struts 1.4.1 31 */ 32 public class ValidWhenResult<T> { 33 /** The current type of the result. */ 34 protected final Class<T> type; 35 36 /** The value of the result. */ 37 protected final T value; 38 39 /** 40 * Constructs this class. 41 * 42 * @param type the current type of 43 * the result 44 * @param value the current value of 45 * the result 46 */ 47 protected ValidWhenResult(Class<T> type, T value) { 48 // System.out.println(">>> " + type + " " + value); 49 this.type = type; 50 this.value = value; 51 } 52 53 /** 54 * Gets the current type of the result. 55 * 56 * @return the current type of the result 57 */ 58 public Class<T> getType() { 59 return type; 60 } 61 62 /** 63 * Gets the current value of the result. 64 * 65 * @return the current value of the result 66 */ 67 public T getValue() { 68 return value; 69 }; 70 71 /** 72 * Gets the {@code Boolean}-value if the 73 * current result is a boolean. 74 * 75 * @return the boolean-value if the value 76 * is a boolean otherwise {@code false}. 77 */ 78 public boolean toBoolean() { 79 return false; 80 } 81 82 @Override 83 public String toString() { 84 return String.valueOf(value); 85 } 86 }