| Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
| PossibleValuesAnnotationHandler |
|
| 0.0;0 |
| 1 | 0 | /* vim: set ts=2 et sw=2 cindent fo=qroca: */ |
| 2 | ||
| 3 | package org.trails.descriptor.annotation; |
|
| 4 | ||
| 5 | import org.apache.commons.lang.Validate; |
|
| 6 | import org.trails.descriptor.IPropertyDescriptor; |
|
| 7 | ||
| 8 | /** |
|
| 9 | * Creates a {@link PossibleValuesDescriptorExtension} using the |
|
| 10 | * information retrieved from a {@link PossibleValues} annotation. |
|
| 11 | * |
|
| 12 | * @author pruggia |
|
| 13 | */ |
|
| 14 | 0 | public class PossibleValuesAnnotationHandler extends AbstractAnnotationHandler |
| 15 | implements DescriptorAnnotationHandler<PossibleValues, IPropertyDescriptor> |
|
| 16 | { |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Creates a {@link PossibleValuesDescriptorExtension} and adds it to the |
|
| 20 | * property descriptor. |
|
| 21 | * |
|
| 22 | * @param annotation Annotation added to the property. It cannot be null. |
|
| 23 | * @param descriptor The property descriptor. It cannot be null. |
|
| 24 | * @return Returns descriptor, with the possible values extension. |
|
| 25 | */ |
|
| 26 | public IPropertyDescriptor decorateFromAnnotation(final PossibleValues annotation, |
|
| 27 | final IPropertyDescriptor descriptor) |
|
| 28 | { |
|
| 29 | 0 | Validate.notNull(annotation, "The annotation cannot be null"); |
| 30 | 0 | Validate.notNull(descriptor, "The descriptor cannot be null"); |
| 31 | ||
| 32 | 0 | PossibleValuesDescriptorExtension extension = new PossibleValuesDescriptorExtension(annotation.value()); |
| 33 | 0 | descriptor.addExtension(PossibleValuesDescriptorExtension.class.getName(), extension); |
| 34 | 0 | return descriptor; |
| 35 | } |
|
| 36 | } |
|
| 37 |