| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractBinding |
|
| 0.0;0 |
| 1 | // Copyright 2006 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.bindings; | |
| 16 | ||
| 17 | import org.apache.tapestry5.Binding; | |
| 18 | import org.apache.tapestry5.ioc.BaseLocatable; | |
| 19 | import org.apache.tapestry5.ioc.Location; | |
| 20 | import org.apache.tapestry5.ioc.internal.util.TapestryException; | |
| 21 | ||
| 22 | import java.lang.annotation.Annotation; | |
| 23 | ||
| 24 | /** | |
| 25 | * Abstract base class for bindings. Assumes that the binding is read only and invariant. Subclasses must provide an | |
| 26 | * implementation of {@link Binding#get()}. | |
| 27 | */ | |
| 28 | public abstract class AbstractBinding extends BaseLocatable implements Binding | |
| 29 | { | |
| 30 | public AbstractBinding() | |
| 31 | { | |
| 32 | 33 | this(null); |
| 33 | 33 | } |
| 34 | ||
| 35 | protected AbstractBinding(Location location) | |
| 36 | { | |
| 37 | 10192 | super(location); |
| 38 | 10192 | } |
| 39 | ||
| 40 | /** | |
| 41 | * @throws TapestryException always | |
| 42 | */ | |
| 43 | public void set(Object value) | |
| 44 | { | |
| 45 | 2 | throw new TapestryException(BindingsMessages.bindingIsReadOnly(this), this, null); |
| 46 | } | |
| 47 | ||
| 48 | /** | |
| 49 | * Returns true. Subclasses that do not supply a fixed, read-only value should override this method to return | |
| 50 | * false. | |
| 51 | */ | |
| 52 | public boolean isInvariant() | |
| 53 | { | |
| 54 | 66226 | return true; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Returns the actual class, by invoking {@link Binding#get()}. Subclasses may override this method to work more | |
| 59 | * efficiently (say, when the binding type is known statically). | |
| 60 | */ | |
| 61 | public Class getBindingType() | |
| 62 | { | |
| 63 | 2 | return get().getClass(); |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Always returns null. Bindings that provide access to a method or field will override this method to return the | |
| 68 | * appropriate annotation. | |
| 69 | */ | |
| 70 | public <T extends Annotation> T getAnnotation(Class<T> annotationClass) | |
| 71 | { | |
| 72 | 0 | return null; |
| 73 | } | |
| 74 | ||
| 75 | } |