|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jdt.internal.compiler.apt.model.Factory
public class Factory
Creates javax.lang.model wrappers around JDT internal compiler bindings.
Field Summary | |
---|---|
static Byte |
DUMMY_BYTE
|
static Character |
DUMMY_CHAR
|
static Double |
DUMMY_DOUBLE
|
static Float |
DUMMY_FLOAT
|
static Integer |
DUMMY_INTEGER
|
static Long |
DUMMY_LONG
|
static Short |
DUMMY_SHORT
|
Constructor Summary | |
---|---|
Factory(BaseProcessingEnvImpl env)
This object should only be constructed by the BaseProcessingEnvImpl. |
Method Summary | |
---|---|
List<? extends AnnotationMirror> |
getAnnotationMirrors(AnnotationBinding[] annotations)
Convert an array of compiler annotation bindings into a list of AnnotationMirror |
ErrorType |
getErrorType(ReferenceBinding binding)
|
static Object |
getMatchingDummyValue(Class<?> expectedType)
|
static Set<Modifier> |
getModifiers(int modifiers,
ElementKind kind)
|
static Set<Modifier> |
getModifiers(int modifiers,
ElementKind kind,
boolean isFromBinary)
Convert from the JDT's ClassFileConstants flags to the Modifier enum. |
NoType |
getNoType(TypeKind kind)
|
NullType |
getNullType()
|
PrimitiveTypeImpl |
getPrimitiveType(TypeKind kind)
Get a type mirror object representing the specified primitive type kind. |
AnnotationMirror |
newAnnotationMirror(AnnotationBinding binding)
|
Element |
newElement(Binding binding)
|
Element |
newElement(Binding binding,
ElementKind kindHint)
Create a new element that knows what kind it is even if the binding is unresolved. |
PackageElement |
newPackageElement(PackageBinding binding)
Convenience method - equivalent to (PackageElement)Factory.newElement(binding) |
TypeMirror |
newTypeMirror(Binding binding)
Given a binding of uncertain type, try to create the right sort of TypeMirror for it. |
TypeParameterElement |
newTypeParameterElement(TypeVariableBinding variable,
Element declaringElement)
|
static Object |
performNecessaryPrimitiveTypeConversion(Class<?> expectedType,
Object value,
boolean avoidReflectException)
This method is derived from code in org.eclipse.jdt.apt.core. |
static void |
setArrayMatchingDummyValue(Object array,
int i,
Class<?> expectedLeafType)
Set an element of an array to the appropriate dummy value type |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Byte DUMMY_BYTE
public static final Character DUMMY_CHAR
public static final Double DUMMY_DOUBLE
public static final Float DUMMY_FLOAT
public static final Integer DUMMY_INTEGER
public static final Long DUMMY_LONG
public static final Short DUMMY_SHORT
Constructor Detail |
---|
public Factory(BaseProcessingEnvImpl env)
Method Detail |
---|
public List<? extends AnnotationMirror> getAnnotationMirrors(AnnotationBinding[] annotations)
public static Object getMatchingDummyValue(Class<?> expectedType)
public static Set<Modifier> getModifiers(int modifiers, ElementKind kind)
public static Set<Modifier> getModifiers(int modifiers, ElementKind kind, boolean isFromBinary)
public AnnotationMirror newAnnotationMirror(AnnotationBinding binding)
public Element newElement(Binding binding, ElementKind kindHint)
public Element newElement(Binding binding)
public PackageElement newPackageElement(PackageBinding binding)
(PackageElement)Factory.newElement(binding)
public NullType getNullType()
public NoType getNoType(TypeKind kind)
public PrimitiveTypeImpl getPrimitiveType(TypeKind kind)
public TypeMirror newTypeMirror(Binding binding)
public TypeParameterElement newTypeParameterElement(TypeVariableBinding variable, Element declaringElement)
declaringElement
- the class, method, etc. that is parameterized by this parameter.public ErrorType getErrorType(ReferenceBinding binding)
public static Object performNecessaryPrimitiveTypeConversion(Class<?> expectedType, Object value, boolean avoidReflectException)
avoidReflectException
is set to true
Return false
if the expected type is boolean
Return numeric 0 for all numeric primitive types and '0' for char
Otherwise:
Return the value unchanged.
In the invocation handler case:
The value returned by InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
will be converted into the expected type by the Proxy
.
If the value and the expected type does not agree, and the value is not null,
a ClassCastException will be thrown. A NullPointerException will result if the
expected type is a primitive type and the value is null.
This behavior causes annotation processors a lot of pain and the decision is
to not throw such unchecked exception. In the case where a ClassCastException or
NullPointerException will be thrown return some dummy value. Otherwise, return
the original value.
Chosen dummy values:
Return false
if the expected type is boolean
Return numeric 0 for all numeric primitive types and '0' for char
This behavior is triggered by setting avoidReflectException
to true
Note: the new behavior deviates from what's documented in
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
and also deviates from
Sun's implementation.
value
- the current value from the annotation instance.expectedType
- the expected type of the value.public static void setArrayMatchingDummyValue(Object array, int i, Class<?> expectedLeafType)
array
- i
- expectedLeafType
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |