本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getConstructors方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getConstructors方法的具體用法?Java JClassType.getConstructors怎麽用?Java JClassType.getConstructors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.getConstructors方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hasPublicDefaultConstructor
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
public static boolean hasPublicDefaultConstructor(JClassType classType){
for (JConstructor constructor : classType.getConstructors()){
if ((constructor.getParameters().length == 0) && constructor.isPublic())
return true;
}
return false;
}
示例2: generateDependenciesForExtension
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Writes dependency gathering code, like:
*
* <p>Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray();
* deps.add(new DependencyDescription("ide.api.ui.menu", "")); deps.add(new
* DependencyDescription("extension.demo", "1.0.0-alpha"));
*
* @param sw
* @param extension
* @throws UnableToCompleteException
*/
private void generateDependenciesForExtension(SourceWriter sw, JClassType extension)
throws UnableToCompleteException {
// expected code
/*
Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray();
deps.add(new DependencyDescription("ide.api.ui.menu", ""));
*/
if (extension.getConstructors().length == 0) {
throw new UnableToCompleteException();
}
sw.println("List<DependencyDescription> deps = new ArrayList<>();");
JConstructor jConstructor = extension.getConstructors()[0];
JType[] parameterTypes = jConstructor.getParameterTypes();
for (JType jType : parameterTypes) {
JClassType argType = jType.isClassOrInterface();
if (argType != null
&& (argType.isAnnotationPresent(SDK.class)
|| argType.isAnnotationPresent(Extension.class))) {
String id = "";
String version = "";
if (argType.isAnnotationPresent(SDK.class)) {
id = argType.getAnnotation(SDK.class).title();
} else if (argType.isAnnotationPresent(Extension.class)) {
id = argType.getQualifiedSourceName();
version = argType.getAnnotation(Extension.class).version();
}
sw.println(
"deps.add(new DependencyDescription(\"%s\", \"%s\"));", escape(id), escape(version));
}
}
}