}
java.util.List<? extends Element> enclosedElements = e.getEnclosedElements();
boolean getInstanceFound = false;
boolean instanceFound = false;
Element instanceElement = null;
Name getInstanceMethName;
Name instanceVarName;
boolean lazy = false;//default
if (ann.getQualifiedName().toString().equals(Singleton.class.getCanonicalName())) {
final Singleton singleton = e.getAnnotation(Singleton.class);
lazy = singleton.lazy();
getInstanceMethName = elementUtils.getName(singleton.getInstance());
instanceVarName = elementUtils.getName(singleton.instance());
} else {
getInstanceMethName = elementUtils.getName(getInstance.class.getSimpleName());
instanceVarName = elementUtils.getName(getInstance.class.getSimpleName());
}
for (final Element element : enclosedElements) {
if (element.getAnnotation(instance.class) != null) {
if (instanceFound == true) {
msgr.printMessage(Kind.ERROR, "Found multiple methods annotated with @instance while at most one must be annotated", e);
}
instanceFound = true;
instanceElement = element;
instanceVarName = elementUtils.getName(element.getSimpleName());
}
if (element.getAnnotation(getInstance.class) != null) {
if (getInstanceFound == true) {
msgr.printMessage(Kind.ERROR, "Found multiple methods annotated with @getInstance while at most one must be annotated", e);
}
getInstanceFound = true;
}
}
if (instanceFound) {
VariableTree tree = (VariableTree) trees.getTree(instanceElement);
ExpressionTree initializer = tree.getInitializer();
if (initializer == null) {
lazy = true;
} else {
lazy = false; //default
}
}
final Name singletonClassName = elementUtils.getName(e.getSimpleName());
JCCompilationUnit singletonCU = (JCCompilationUnit) trees.getPath(e).getCompilationUnit();
JCMethodDecl defCon = null;
JCExpression defConInit = null;
for (JCTree def : singletonCU.defs) {