|
Lombok.ast - v0.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlombok.ast.resolve.Resolver
public class Resolver
Contains simplistic (guesstimations) resolution that doesn't require full resolution and symbol lookup but it isn't perfect.
Constructor Summary | |
---|---|
Resolver()
|
Method Summary | ||
---|---|---|
String |
getAnnotationClassAsString(Annotation annotation,
String methodName)
Use together with toAnnotationInstance(Class, Annotation) . |
|
List<String> |
getAnnotationClassesAsStrings(Annotation annotation,
String methodName)
Use together with toAnnotationInstance(Class, Annotation) . |
|
|
resolveEnum(Class<E> enumClass,
Node value)
If value is an enum constant of type enumClass , then the enum value will be returned. |
|
|
toAnnotationInstance(Class<A> type,
Annotation node)
Turns an annotation AST node into an actual instance of an annotation class provided you already know its type. |
|
boolean |
typesMatch(String wanted,
TypeReference typeReference)
Checks if the given typeReference could legally be referring to the listed fully qualified typeName . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Resolver()
Method Detail |
---|
public <E extends Enum<E>> E resolveEnum(Class<E> enumClass, Node value)
value
is an enum constant of type enumClass
, then the enum value will be returned.
null
will be returned if value
is an actual null literal.
ResolutionException
- If value
cannot be converted.public boolean typesMatch(String wanted, TypeReference typeReference)
typeReference
could legally be referring to the listed fully qualified typeName
.
Will check import statements, and checks for any shadowing by types in this file with the same name.
WARNING: This method will return true
if there's a star import of i.e. java.util.*
,
you ask if ArrayList
could be referring to java.util.ArrayList
, and there is another class in the same package also named
ArrayList
. The right answer is of course false
, but without a classpath/sourcepath this cannot be determined. Therefore,
this method is 99% but not 100% accurate. Also, god kills a puppy everytime you write a star import.
NB: Any type arguments (generics) on either the typeReference
or wanted
are stripped off before comparing the two.
NB: If you want array types, just put array brackets at the end of your wanted
string, for example: "java.lang.String[]
".
wanted
- A fully qualified type name, such as java.lang.String
.typeReference
- A type reference node.
true
if the typeReference is most likely a reference to wanted
.public <A extends Annotation> A toAnnotationInstance(Class<A> type, Annotation node)
resolver.getAnnotationClassAsString(objectReturnedByThisMethod, "annotation method name")
.
getAnnotationClassesAsStrings(java.lang.annotation.Annotation, String)
,
getAnnotationClassAsString(java.lang.annotation.Annotation, String)
public String getAnnotationClassAsString(Annotation annotation, String methodName)
toAnnotationInstance(Class, Annotation)
.
getAnnotationClassesAsStrings(java.lang.annotation.Annotation, String)
public List<String> getAnnotationClassesAsStrings(Annotation annotation, String methodName)
toAnnotationInstance(Class, Annotation)
.
getAnnotationClassAsString(java.lang.annotation.Annotation, String)
|
Lombok.ast - v0.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |