| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PropertyModel |
|
| 1.0;1 |
| 1 | // Copyright 2007, 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.beaneditor; | |
| 16 | ||
| 17 | import org.apache.tapestry5.PropertyConduit; | |
| 18 | import org.apache.tapestry5.ioc.AnnotationProvider; | |
| 19 | ||
| 20 | /** | |
| 21 | * Part of a {@link org.apache.tapestry5.beaneditor.BeanModel} that defines the attributes of a single property of a | |
| 22 | * bean. | |
| 23 | * <p/> | |
| 24 | * <p/> | |
| 25 | * A PropertyModel is also an {@link AnnotationProvider}, as long as the {@link org.apache.tapestry5.PropertyConduit} is | |
| 26 | * non-null. When there is no property conduit, then {@link org.apache.tapestry5.ioc.AnnotationProvider#getAnnotation(Class)} | |
| 27 | * will return null. | |
| 28 | */ | |
| 29 | public interface PropertyModel extends AnnotationProvider | |
| 30 | { | |
| 31 | /** | |
| 32 | * Returns the name of the property (which may, in fact, be a property expression). | |
| 33 | */ | |
| 34 | String getPropertyName(); | |
| 35 | ||
| 36 | /** | |
| 37 | * Returns the id used to access other resources (this is based on the property name, but with any excess | |
| 38 | * punctuation stripped out). | |
| 39 | */ | |
| 40 | String getId(); | |
| 41 | ||
| 42 | /** | |
| 43 | * Returns a user-presentable label for the property. | |
| 44 | */ | |
| 45 | String getLabel(); | |
| 46 | ||
| 47 | /** | |
| 48 | * Returns the type of the property. | |
| 49 | */ | |
| 50 | Class getPropertyType(); | |
| 51 | ||
| 52 | /** | |
| 53 | * Returns a logical name for the type of UI needed to view or edit the property. This is initially determined from | |
| 54 | * the property type. | |
| 55 | */ | |
| 56 | String getDataType(); | |
| 57 | ||
| 58 | /** | |
| 59 | * Changes the data type for the property. | |
| 60 | * | |
| 61 | * @param dataType | |
| 62 | * @return the property model, for further changes | |
| 63 | */ | |
| 64 | PropertyModel dataType(String dataType); | |
| 65 | ||
| 66 | /** | |
| 67 | * Returns an object used to read or update the property. For virtual properties (properties that do not actually | |
| 68 | * exist on the bean), the conduit may be null. | |
| 69 | */ | |
| 70 | PropertyConduit getConduit(); | |
| 71 | ||
| 72 | /** | |
| 73 | * Changes the label for the property to the provided value. | |
| 74 | * | |
| 75 | * @param label new label for property | |
| 76 | * @return the property model, for further changes | |
| 77 | */ | |
| 78 | PropertyModel label(String label); | |
| 79 | ||
| 80 | /** | |
| 81 | * Returns the containing model, often used for "fluent" construction of the model. | |
| 82 | */ | |
| 83 | BeanModel model(); | |
| 84 | ||
| 85 | /** | |
| 86 | * Returns true if the property can be used for sorting. By default, this is true only if the property type | |
| 87 | * implements Comparable. | |
| 88 | */ | |
| 89 | boolean isSortable(); | |
| 90 | ||
| 91 | /** | |
| 92 | * Updates sortable and returns the model for further changes. | |
| 93 | * | |
| 94 | * @return the property model, for further changes | |
| 95 | */ | |
| 96 | PropertyModel sortable(boolean sortable); | |
| 97 | } |