01: /*
02: * Copyright 2006-2007, Unitils.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.unitils.inject.annotation;
17:
18: import org.unitils.inject.util.PropertyAccess;
19:
20: import static java.lang.annotation.ElementType.FIELD;
21: import java.lang.annotation.Retention;
22: import static java.lang.annotation.RetentionPolicy.RUNTIME;
23: import java.lang.annotation.Target;
24:
25: /**
26: * Annotation indicating that the the {@link org.unitils.inject.InjectModule} should try to inject the object assigned to
27: * the annotated field to the object defined by the target attribute (or the object(s) assigned to the field annotated
28: * with {@link TestedObject}.
29: * <p/>
30: * Automatic injection by type is used, which means that the object is injected to the most specific property with an
31: * assignable type.
32: *
33: * @author Filip Neven
34: * @author Tim Ducheyne
35: */
36: @Target(FIELD)
37: @Retention(RUNTIME)
38: public @interface InjectIntoByType {
39:
40: /**
41: * The name of the field that references the object to which the object in the annotated field should be injected.
42: * If not specified, the target is defined by the field annotated with {@link TestedObject}
43: *
44: * @return the target field, null for tested object
45: */
46: String target() default "";
47:
48: /**
49: * The property access that should be used for injection.
50: *
51: * @return the access type, not null
52: */
53: PropertyAccess propertyAccess() default PropertyAccess.DEFAULT;
54:
55: }
|