/**
* XmlType allows specification of factoryClass and
* factoryMethod. There are to be used if no default
* constructor is found.
*
* @return
* true if the factory method was found. False if not.
*/
private boolean hasFactoryConstructor(XmlType t){
if (t == null) return false;
String method = t.factoryMethod();
T fClass = reader().getClassValue(t, "factoryClass");
if (method.length() > 0){
if(nav().isSameType(fClass, nav().ref(XmlType.DEFAULT.class))){
fClass = nav().use(clazz);
}
for(M m: nav().getDeclaredMethods(nav().asDecl(fClass))){
//- Find the zero-arg public static method with the required return type
if (nav().getMethodName(m).equals(method) &&
nav().isSameType(nav().getReturnType(m), nav().use(clazz)) &&
nav().getMethodParameters(m).length == 0 &&
nav().isStaticMethod(m)){
factoryMethod = m;
break;
}
}
if (factoryMethod == null){
builder.reportError(new IllegalAnnotationException(
Messages.NO_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass)), method), this ));
}
} else if(!nav().isSameType(fClass, nav().ref(XmlType.DEFAULT.class))){
builder.reportError(new IllegalAnnotationException(
Messages.FACTORY_CLASS_NEEDS_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass))), this ));
}
return factoryMethod != null;
}
ClassInfoImpl.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录