| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractValidator |
|
| 0.0;0 |
| 1 | // Copyright 2008 The Apache Software Foundation | |
| 2 | // | |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | // you may not use this file except in compliance with the License. | |
| 5 | // You may obtain a copy of the License at | |
| 6 | // | |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | // | |
| 9 | // Unless required by applicable law or agreed to in writing, software | |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | // See the License for the specific language governing permissions and | |
| 13 | // limitations under the License. | |
| 14 | ||
| 15 | package org.apache.tapestry5.validator; | |
| 16 | ||
| 17 | import org.apache.tapestry5.Validator; | |
| 18 | ||
| 19 | /** | |
| 20 | * Base class for constructing a {@link org.apache.tapestry5.Validator}. | |
| 21 | */ | |
| 22 | public abstract class AbstractValidator<C, T> implements Validator<C, T> | |
| 23 | { | |
| 24 | private final Class<C> constraintType; | |
| 25 | ||
| 26 | private final Class<T> valueType; | |
| 27 | ||
| 28 | private final String messageKey; | |
| 29 | ||
| 30 | protected AbstractValidator(Class<C> constraintType, Class<T> valueType, String messageKey) | |
| 31 | 44 | { |
| 32 | 44 | this.constraintType = constraintType; |
| 33 | 44 | this.valueType = valueType; |
| 34 | 44 | this.messageKey = messageKey; |
| 35 | 44 | } |
| 36 | ||
| 37 | public final Class<C> getConstraintType() | |
| 38 | { | |
| 39 | 520 | return constraintType; |
| 40 | } | |
| 41 | ||
| 42 | public final Class<T> getValueType() | |
| 43 | { | |
| 44 | 248 | return valueType; |
| 45 | } | |
| 46 | ||
| 47 | public final String getMessageKey() | |
| 48 | { | |
| 49 | 454 | return messageKey; |
| 50 | } | |
| 51 | ||
| 52 | /** | |
| 53 | * Return false, which is correct for the vast majority of validators. {@link org.apache.tapestry5.validator.Required} | |
| 54 | * overrides this to true.F | |
| 55 | */ | |
| 56 | public boolean isRequired() | |
| 57 | { | |
| 58 | 54 | return false; |
| 59 | } | |
| 60 | } |