@Retention(value=RUNTIME) @Target(value={FIELD,PARAMETER,ANNOTATION_TYPE}) public @interface Depend
value()
和 type()
参数生效,
优先考虑value()
,如果value没有填入则使用类型注入。
假如不使用此注解也会进行注入,但是假若没有开启编译指令的话可能会无法正确注入Modifier and Type | Optional Element and Description |
---|---|
boolean |
byGetter
是否使用getter方法对字段的可否注入进行判断,默认为false,即直接判断字段的值
|
boolean |
bySetter
是否使用setter方法对字段进行赋值注入,默认为false,即直接对字段值进行操作
|
String |
getterName
|
boolean |
nonNull
是否当字段值不为null的时候再进行注入,一般用于避免与其他依赖注入的参数出现冲突,默认为true
只有此值为true的时候
byGetter() 才会生效
否则将不进行判断,直接注入 |
boolean |
orNull
Deprecated.
|
String |
setterName
|
Class[] |
type
如果要使用字段类型进行注入,但是此类型可能存在多个(不同实现类),
那么使用此参数来指定类型 虽然类型为数组,但是仅只能使用一个类型,如果有多个则只取第一个. Get the first element only |
String |
value
使用名称对依赖进行注入,如果为空字符串则使用类型进行注入
|
public abstract String value
@Deprecated public abstract boolean orNull
public abstract Class[] type
public abstract boolean nonNull
byGetter()
才会生效
否则将不进行判断,直接注入public abstract boolean byGetter
public abstract String getterName
public abstract String setterName
Copyright © 2020. All rights reserved.