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 java.lang.reflect.Field;
19
20 /**
21 * Implementors create {@link ObjectFactory} instances that require runtime information.
22 *
23 * @author Steve Chaloner
24 * @version <!-- $Revision$ -->, <!-- $Date$ -->
25 */
26 public interface TypeFactory<T>
27 {
28 /**
29 * Creates a new instance of the target class with the correct runtime types.
30 *
31 * @param classes the generic parameter types
32 * @param field the target field
33 * @return a new instance of the target class
34 */
35 ObjectFactory<T> createObjectFactory(Class[] classes,
36 Field field);
37
38 /**
39 * Get the class type handled by this factory.
40 *
41 * @return the class
42 */
43 Class<T> getBoundClass();
44
45 /**
46 * Determines the runtime generic parameter of the target class.
47 *
48 * @param fieldType the class type of the field
49 * @param genericTypes the generic types declared for the field
50 * @return the runtime generic values
51 */
52 Class[] determineClassType(Class fieldType,
53 GenericTypes genericTypes);
54 }