| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ObjectFactory |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 2009-2010 Steve Chaloner | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package be.objectify.led; | |
| 17 | ||
| 18 | import be.objectify.led.validation.ValidationFunction; | |
| 19 | ||
| 20 | /** | |
| 21 | * Object factories are used to convert string property values into objects of an specific type. | |
| 22 | * | |
| 23 | * @author Steve Chaloner | |
| 24 | */ | |
| 25 | public interface ObjectFactory<T> | |
| 26 | { | |
| 27 | /** | |
| 28 | * Creates an object based on propertyValue. If propertyValue is null | |
| 29 | * or no object can be based on it, null should be returned. | |
| 30 | * | |
| 31 | * @param propertyValue the value of the property | |
| 32 | * @return an object (probably) based on propertyValue, or null | |
| 33 | */ | |
| 34 | T createObject(String propertyName, | |
| 35 | String propertyValue); | |
| 36 | ||
| 37 | /** | |
| 38 | * Gets the class type this factory produces objects for. | |
| 39 | * | |
| 40 | * @return the class type | |
| 41 | */ | |
| 42 | Class<T> getBoundClass(); | |
| 43 | ||
| 44 | /** | |
| 45 | * Validations the value for the field. | |
| 46 | * | |
| 47 | * @param propertyName the name of the property | |
| 48 | * @param propertyValue the value from the @{link PropertyContext} | |
| 49 | * @param validationFunctions functions to validate the property value | |
| 50 | * @throws be.objectify.led.validation.ValidationException if the property value isn't valid | |
| 51 | */ | |
| 52 | public void validate(String propertyName, | |
| 53 | String propertyValue, | |
| 54 | ValidationFunction... validationFunctions); | |
| 55 | } |