public class BeanSpec
extends java.lang.Object
implements org.osgl.util.AnnotationAware
Specification of a bean to be injected.
| Modifier and Type | Method and Description |
|---|---|
java.lang.annotation.Annotation[] |
allAnnotations() |
boolean |
equals(java.lang.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 |
<T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<T> annoClass) |
int |
getModifiers() |
boolean |
hasAnnotation() |
boolean |
hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass) |
int |
hashCode() |
Injector |
injector() |
boolean |
isArray() |
boolean |
isFinal() |
boolean |
isInstance(java.lang.Object o)
Check if a given object is instance of the type of this bean spec.
|
boolean |
isInstanceOf(java.lang.Class c)
Return if the bean is instance of give class.
|
boolean |
isPrivate() |
boolean |
isProtected() |
boolean |
isPublic() |
boolean |
isStatic() |
boolean |
isTransient() |
java.lang.String |
name() |
static BeanSpec |
of(java.lang.Class<?> clazz,
Injector injector) |
static BeanSpec |
of(java.lang.reflect.Field field,
Injector injector) |
static BeanSpec |
of(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] paramAnnotations,
Injector injector) |
static BeanSpec |
of(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] paramAnnotations,
Injector injector,
int modifiers) |
static BeanSpec |
of(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] paramAnnotations,
java.lang.String name,
Injector injector) |
static BeanSpec |
of(java.lang.reflect.Type type,
java.lang.annotation.Annotation[] paramAnnotations,
java.lang.String name,
Injector injector,
int modifiers) |
static BeanSpec |
of(java.lang.reflect.Type type,
Injector injector) |
java.util.Set<java.lang.annotation.Annotation> |
qualifiers()
Returns all qualifier annotation of this bean spec.
|
java.lang.Class |
rawType() |
static java.lang.Class<?> |
rawTypeOf(java.lang.reflect.Type type)
A utility method to return raw type (the class) of a given type.
|
java.lang.annotation.Annotation[] |
taggedAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> tagType) |
BeanSpec |
toList()
Convert an array bean spec to a list bean spec.
|
java.lang.String |
toString() |
java.lang.reflect.Type |
type() |
java.util.List<java.lang.reflect.Type> |
typeParams()
Returns a list of type parameters if the
type() of the bean is instance of ParameterizedType. |
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.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.
equals in class java.lang.Objectobj - the object to compare with this objecttrue if the two objects equals as per described abovepublic java.lang.String toString()
toString in class java.lang.Objectpublic Injector injector()
public java.lang.reflect.Type type()
public java.lang.Class rawType()
public java.lang.String name()
public boolean isArray()
public java.lang.annotation.Annotation[] allAnnotations()
public java.lang.annotation.Annotation[] taggedAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> tagType)
public BeanSpec toList()
Convert an array bean spec to a list bean spec.
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annoClass)
getAnnotation in interface org.osgl.util.AnnotationAwarepublic boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
hasAnnotation in interface org.osgl.util.AnnotationAwarepublic boolean hasAnnotation()
public int getModifiers()
public boolean isTransient()
public boolean isStatic()
public boolean isPrivate()
public boolean isPublic()
public boolean isProtected()
public boolean isFinal()
public java.util.List<java.lang.reflect.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 boolean isInstanceOf(java.lang.Class c)
Return if the bean is instance of give class.
c - the classtrue if the underline bean is an instance of cpublic boolean isInstance(java.lang.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 java.util.Set<java.lang.annotation.Annotation> qualifiers()
Returns all qualifier annotation of this bean spec.
public static BeanSpec of(java.lang.reflect.Type type, java.lang.annotation.Annotation[] paramAnnotations, Injector injector)
public static BeanSpec of(java.lang.reflect.Type type, java.lang.annotation.Annotation[] paramAnnotations, Injector injector, int modifiers)
public static BeanSpec of(java.lang.reflect.Type type, java.lang.annotation.Annotation[] paramAnnotations, java.lang.String name, Injector injector)
public static BeanSpec of(java.lang.reflect.Type type, java.lang.annotation.Annotation[] paramAnnotations, java.lang.String name, Injector injector, int modifiers)
public static java.lang.Class<?> rawTypeOf(java.lang.reflect.Type type)
A utility method to return raw type (the class) of a given type.
type - a TypeClass of the typeorg.osgl.exception.UnexpectedException - if class cannot be determinedCopyright © 2016–2017 OSGL (Open Source General Library). All rights reserved.