| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractSpecificPropertyHandler |
|
| 0.0;0 |
| 1 | /* | |
| 2 | ORG Usurper is a random value object generator library | |
| 3 | Copyright (C) 2007 Pierre-Antoine Grégoire | |
| 4 | | |
| 5 | This library is free software; you can redistribute it and/or | |
| 6 | modify it under the terms of the GNU Lesser General Public | |
| 7 | License as published by the Free Software Foundation; either | |
| 8 | version 2.1 of the License, or (at your option) any later version. | |
| 9 | | |
| 10 | This library is distributed in the hope that it will be useful, | |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | Lesser General Public License for more details. | |
| 14 | | |
| 15 | You should have received a copy of the GNU Lesser General Public | |
| 16 | License along with this library; if not, write to the Free Software | |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 18 | */ | |
| 19 | ||
| 20 | package org.org.usurper.handlers.basic; | |
| 21 | ||
| 22 | import org.org.usurper.handlers.IHandler; | |
| 23 | import org.org.usurper.model.SpecificPropertyDefinition; | |
| 24 | ||
| 25 | /** | |
| 26 | * This is the class to extend in order to implement a handler for a specific property of a given class. | |
| 27 | * | |
| 28 | * @author pagregoire | |
| 29 | */ | |
| 30 | public abstract class AbstractSpecificPropertyHandler implements IHandler { | |
| 31 | ||
| 32 | /** The target property class. */ | |
| 33 | private SpecificPropertyDefinition specificPropertyDefinition; | |
| 34 | ||
| 35 | /** | |
| 36 | * This constructor takes a SpecificPropertyDefinition as a parameter | |
| 37 | * @param specificPropertyDefinition | |
| 38 | */ | |
| 39 | 10 | public AbstractSpecificPropertyHandler(SpecificPropertyDefinition specificPropertyDefinition) { |
| 40 | 10 | this.specificPropertyDefinition = specificPropertyDefinition; |
| 41 | 10 | } |
| 42 | ||
| 43 | /** | |
| 44 | * This constructor takes a class and a field name as parameters | |
| 45 | * @param valueObjectClass | |
| 46 | * @param handledFieldName | |
| 47 | */ | |
| 48 | 0 | public AbstractSpecificPropertyHandler(Class<?> valueObjectClass, String handledFieldName) { |
| 49 | 0 | this.specificPropertyDefinition = new SpecificPropertyDefinition(valueObjectClass, handledFieldName); |
| 50 | 0 | } |
| 51 | ||
| 52 | /** | |
| 53 | * Gets the handled property name. | |
| 54 | * | |
| 55 | * @return Returns the handledType. | |
| 56 | * @deprecated prefer access through the specificPropertyDefinition attribute | |
| 57 | */ | |
| 58 | public String getHandledPropertyName() { | |
| 59 | 0 | return specificPropertyDefinition.getTargetProperty(); |
| 60 | } | |
| 61 | ||
| 62 | /** | |
| 63 | * Sets the handled property name. | |
| 64 | * | |
| 65 | * @param handledFieldName | |
| 66 | * the handled field name | |
| 67 | * @deprecated prefer the constructor | |
| 68 | */ | |
| 69 | public void setHandledPropertyName(String handledFieldName) { | |
| 70 | 0 | this.specificPropertyDefinition = new SpecificPropertyDefinition(specificPropertyDefinition.getTargetClass(), handledFieldName); |
| 71 | 0 | } |
| 72 | ||
| 73 | /** | |
| 74 | * Gets the value object class. | |
| 75 | * | |
| 76 | * @return Returns the valueObjectClass. | |
| 77 | * @deprecated prefer access through the specificPropertyDefinition attribute | |
| 78 | */ | |
| 79 | public Class<?> getValueObjectClass() { | |
| 80 | 0 | return this.specificPropertyDefinition.getTargetClass(); |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * Sets the value object class. | |
| 85 | * | |
| 86 | * @param valueObjectClass | |
| 87 | * The valueObjectClass to set. | |
| 88 | * @deprecated prefer the constructor | |
| 89 | */ | |
| 90 | public void setValueObjectClass(Class<?> valueObjectClass) { | |
| 91 | 0 | this.specificPropertyDefinition = new SpecificPropertyDefinition(valueObjectClass, specificPropertyDefinition.getTargetProperty()); |
| 92 | 0 | } |
| 93 | ||
| 94 | /** | |
| 95 | * Gets the target property definition. | |
| 96 | * | |
| 97 | * @return the target property | |
| 98 | */ | |
| 99 | public SpecificPropertyDefinition getTargetProperty() { | |
| 100 | 8 | return specificPropertyDefinition; |
| 101 | } | |
| 102 | } |