| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ParameterAccess |
|
| 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.internal; | |
| 16 | ||
| 17 | import org.apache.tapestry5.ioc.AnnotationProvider; | |
| 18 | ||
| 19 | /** | |
| 20 | * A wrapper around a named parameter provided by {@link org.apache.tapestry5.internal.InternalComponentResources}. The | |
| 21 | * parameter may be bound or unbound. | |
| 22 | * | |
| 23 | * @since 5.0.19 | |
| 24 | */ | |
| 25 | public interface ParameterAccess extends AnnotationProvider | |
| 26 | { | |
| 27 | /** | |
| 28 | * Is the parameter bound? | |
| 29 | * | |
| 30 | * @return true if bound | |
| 31 | */ | |
| 32 | boolean isBound(); | |
| 33 | ||
| 34 | /** | |
| 35 | * Reads the current value of the parameter via the parameter's {@link org.apache.tapestry5.Binding}. This method is | |
| 36 | * intended for use from generated code (where it is easier to specify the type as a name than a Class instance). | |
| 37 | * | |
| 38 | * @param desiredTypeName the fully qualified name of the Java type to coerce the result to | |
| 39 | * @return the value of the parameter, or null if not bound | |
| 40 | * @throws NullPointerException if the parameter's value is null and null is not allowed | |
| 41 | */ | |
| 42 | Object read(String desiredTypeName); | |
| 43 | ||
| 44 | ||
| 45 | /** | |
| 46 | * Reads the value of a parameter, via the parameter's {@link org.apache.tapestry5.Binding}. | |
| 47 | * | |
| 48 | * @param <T> | |
| 49 | * @param expectedType the expected type of parameter | |
| 50 | * @return the value for the parameter, or null if the parameter is not bound. | |
| 51 | */ | |
| 52 | <T> T read(Class<T> expectedType); | |
| 53 | ||
| 54 | /** | |
| 55 | * Updates the parameter to a new value. If the parameter is not bound, this method does nothing. | |
| 56 | * | |
| 57 | * @param parameterValue new value for parameter | |
| 58 | * @param <T> | |
| 59 | */ | |
| 60 | <T> void write(T parameterValue); | |
| 61 | ||
| 62 | /** | |
| 63 | * Returns true if the binding is bound, and the binding is invariant. | |
| 64 | * | |
| 65 | * @return true if invariant | |
| 66 | * @see org.apache.tapestry5.Binding#isInvariant() | |
| 67 | */ | |
| 68 | boolean isInvariant(); | |
| 69 | ||
| 70 | /** | |
| 71 | * Returns the actual type of the bound parameter, or null if the parameter is not bound. This is primarily used | |
| 72 | * with property bindings, and is used to determine the actual type of the property, rather than the type of | |
| 73 | * parameter (remember that type coercion automatically occurs, which can mask significant differences between the | |
| 74 | * parameter type and the bound property type). | |
| 75 | * | |
| 76 | * @return the type of the bound parameter, or null if the parameter is not bound | |
| 77 | * @see org.apache.tapestry5.Binding#getBindingType() | |
| 78 | */ | |
| 79 | Class getBoundType(); | |
| 80 | } |