public class BeanSpec extends Object implements org.osgl.util.AnnotationAware
Specification of a bean to be injected.
Modifier and Type | Method and Description |
---|---|
Annotation[] |
allAnnotations() |
BeanSpec |
componentSpec() |
boolean |
equals(Object obj)
A bean spec equals to another bean spec if all of the following conditions are met: * the
type of the two bean spec equals to each other * the annotations of the two bean spec equals to each other |
BeanSpec |
field(String name) |
Map<String,BeanSpec> |
fields()
Returns a list of
BeanSpec for all fields including super class fields. |
List<BeanSpec> |
fields(org.osgl.Lang.Predicate<Field> filter)
Returns a list of
BeanSpec for all fields including super class fields. |
<T extends Annotation> |
getAnnotation(Class<T> annoClass) |
int |
getModifiers() |
boolean |
hasAnnotation() |
boolean |
hasAnnotation(Class<? extends Annotation> annoClass) |
int |
hashCode() |
boolean |
hasInjectDecorator()
Check if the bean spec has injector decorators.
|
Injector |
injector() |
boolean |
isArray() |
boolean |
isFinal() |
boolean |
isInstance(Object o)
Check if a given object is instance of the type of this bean spec.
|
boolean |
isInstanceOf(Class c)
Return if the bean is instance of give class.
|
boolean |
isInterface() |
boolean |
isNotObject() |
boolean |
isObject() |
boolean |
isPrivate() |
boolean |
isProtected() |
boolean |
isPublic() |
boolean |
isStatic() |
boolean |
isTransient() |
String |
name() |
List<BeanSpec> |
nonStaticFields() |
static BeanSpec |
of(Class<?> clazz,
Injector injector) |
static BeanSpec |
of(Field field,
Injector injector) |
static BeanSpec |
of(Type type,
Annotation[] paramAnnotations,
Injector injector) |
static BeanSpec |
of(Type type,
Annotation[] paramAnnotations,
Injector injector,
int modifiers) |
static BeanSpec |
of(Type type,
Annotation[] paramAnnotations,
String name,
Injector injector) |
static BeanSpec |
of(Type type,
Annotation[] paramAnnotations,
String name,
Injector injector,
int modifiers) |
static BeanSpec |
of(Type type,
Injector injector) |
BeanSpec |
parent() |
Set<Annotation> |
qualifiers()
Returns all qualifier annotation of this bean spec.
|
Class |
rawType() |
static Class<?> |
rawTypeOf(Type type)
A utility method to return raw type (the class) of a given type.
|
Annotation[] |
taggedAnnotations(Class<? extends Annotation> tagType) |
BeanSpec |
toList()
Convert an array bean spec to a list bean spec.
|
String |
toString() |
Type |
type() |
List<Type> |
typeParams()
Returns a list of type parameters if the
type() of the bean is instance of ParameterizedType . |
BeanSpec |
withoutName() |
public boolean equals(Object obj)
A bean spec equals to another bean spec if all of the following conditions are met: * the type
of the two bean spec equals to each other * the annotations
of the two bean spec equals to each other
Specifically, scope
does not participate comparison because 1. Scope annotations shall be put onto type
, or the factory method with Provides
annotation, which is equivalent to Type
. So it is safe to ignore scope annotation because one type cannot be annotated with different scope 2. If we count scope annotation in equality test, we will never be able to get the correct provider stem from the factory methods.
public Injector injector()
public Type type()
public Class rawType()
public String name()
public boolean isArray()
public Annotation[] allAnnotations()
public Annotation[] taggedAnnotations(Class<? extends Annotation> tagType)
public BeanSpec toList()
Convert an array bean spec to a list bean spec.
public <T extends Annotation> T getAnnotation(Class<T> annoClass)
getAnnotation
in interface org.osgl.util.AnnotationAware
public boolean hasAnnotation(Class<? extends Annotation> annoClass)
hasAnnotation
in interface org.osgl.util.AnnotationAware
public boolean hasAnnotation()
public int getModifiers()
public boolean isTransient()
public boolean isStatic()
public boolean isPrivate()
public boolean isPublic()
public boolean isProtected()
public boolean isFinal()
public boolean isInterface()
public BeanSpec withoutName()
public List<Type> typeParams()
Returns a list of type parameters if the type()
of the bean is instance of ParameterizedType
.
For example the bean spec of a field declared as
private Map<String, Integer> scores;
The typeParams()
method will return a list of String
and Integer
public BeanSpec componentSpec()
public boolean isInstanceOf(Class c)
Return if the bean is instance of give class.
c
- the classtrue
if the underline bean is an instance of c
public boolean isInstance(Object o)
Check if a given object is instance of the type of this bean spec.
o
- the object instancetrue
if the object is an instance of type of this bean specpublic boolean hasInjectDecorator()
Check if the bean spec has injector decorators. The following annotations are considered to be inject decorators: * qualifiers * post construct annotation * scope annotation * Inject
or any annotation has InjectTag
presented
true
if the beanSpec has inject decorators or false
otherwisepublic Set<Annotation> qualifiers()
Returns all qualifier annotation of this bean spec.
public BeanSpec parent()
public boolean isObject()
public boolean isNotObject()
public Map<String,BeanSpec> fields()
Returns a list of BeanSpec
for all fields including super class fields.
public List<BeanSpec> fields(org.osgl.Lang.Predicate<Field> filter)
Returns a list of BeanSpec
for all fields including super class fields.
filter
- a function to filter out fields that are not needed.public static BeanSpec of(Type type, Annotation[] paramAnnotations, Injector injector)
public static BeanSpec of(Type type, Annotation[] paramAnnotations, Injector injector, int modifiers)
public static BeanSpec of(Type type, Annotation[] paramAnnotations, String name, Injector injector)
public static BeanSpec of(Type type, Annotation[] paramAnnotations, String name, Injector injector, int modifiers)
Copyright © 2016–2018 OSGL (Open Source General Library). All rights reserved.