本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getMethods方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getMethods方法的具體用法?Java JClassType.getMethods怎麽用?Java JClassType.getMethods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.getMethods方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMethodNames
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private Set<String> getMethodNames(String className, TreeLogger logger,
TypeOracle typeOracle) throws UnableToCompleteException {
JClassType baseClass = typeOracle.findType(className);
if (baseClass == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + baseClass + "'", null);
throw new UnableToCompleteException();
}
Set<String> result = new HashSet<String>();
for (JMethod method : baseClass.getMethods()) {
if (!method.isPrivate()) {
result.add(method.getName());
}
}
return result;
}
示例2: processRelationClasses
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private void processRelationClasses(List<JClassType> types, JClassType classType){
if (classType.getSuperclass() != null){
processRelationClasses(types, classType.getSuperclass());
addClassIfNotExists(types, classType.getSuperclass());
}
for (JClassType type : classType.getImplementedInterfaces()){
addClassIfNotExists(types, type);
}
for (JField field : classType.getFields()) {
addClassIfNotExists(types, field.getType().isClassOrInterface());
}
for (JMethod method : classType.getMethods()){
if (method.getReturnType() != null)
addClassIfNotExists(types, method.getReturnType().isClassOrInterface());
//TODO How about parameters?
}
}
示例3: createModule
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private String createModule(TreeLogger logger, GeneratorContext context, JClassType requestedType,
String packageName, String requestedName) {
String moduleName = requestedName + "Module";
ClassSourceFileComposerFactory moduleFactory =
new ClassSourceFileComposerFactory(packageName, moduleName);
moduleFactory.setSuperclass(AbstractGinModule.class.getCanonicalName());
moduleFactory.addImport(Names.class.getCanonicalName());
SourceWriter moduleWriter = moduleFactory.createSourceWriter(context,
context.tryCreate(logger, packageName, moduleName));
moduleWriter.println("public void configure() {");
moduleWriter.indent();
for (JMethod method : requestedType.getMethods()) {
if (method.getName().startsWith("set")) {
String name = method.getParameters()[0].getAnnotation(Named.class).value();
moduleWriter.println("bindConstant().annotatedWith(Names.named(\"" + name + "\")).to(\""
+ Math.pow(Integer.parseInt(name), 2) + "\");");
}
}
moduleWriter.outdent();
moduleWriter.println("}");
moduleWriter.commit(logger);
return moduleName;
}
示例4: findTests
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
public static List<JMethod> findTests(
TreeLogger logger, GeneratorContext context, JClassType classType)
throws UnableToCompleteException {
if (DEBUG) logger = logger.branch(TreeLogger.WARN,
"Finding tests for class: " + classType.getName());
List<JMethod> tests = new ArrayList<JMethod>();
for (JMethod method : classType.getMethods()) {
if (method.getName().startsWith("test")) {
if (DEBUG) logger.log(TreeLogger.WARN, "Found test: " + method.getName());
verifyTestSignature(logger, classType, method);
tests.add(method);
}
}
return tests;
}
示例5: getAllAnnotations
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Get All annotations from classType
* NOTE: This is ordered by ParentClass to DevidedClass
* The parentclass's annotation comes first
* @param <T>
* @param classType
* @param annotationClass
* @return
*/
public static <T extends Annotation> Map<Object, T> getAllAnnotations(JClassType classType, Class<T> annotationClass){
Map<Object, T> results = new HashMap<Object, T>();
JClassType parent = classType.getSuperclass();
if (parent != null){
results.putAll(getAllAnnotations(parent, annotationClass));
}
T a = classType.getAnnotation(annotationClass);
if (a != null){
results.put(classType, a);
}
for (JField field : classType.getFields()){
a = field.getAnnotation(annotationClass);
if (a != null)
results.put(field, a);
}
for (JMethod method : classType.getMethods()){
a = method.getAnnotation(annotationClass);
if (a != null)
results.put(method, a);
}
return results;
}
示例6: generateExtendedProxy
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Generates a wrapper around the proxy generated by
* {@link ServiceInterfaceProxyGenerator}.
*
* @param logger log interface
* @param context generator context
* @param typeName name of the interface that was passed to
* {@link com.google.gwt.core.client.GWT#create(Class)}
* @param proxyTypeName the name of the wrapped proxy class
* @return the name of the extended proxy class
*/
private String generateExtendedProxy(TreeLogger logger, GeneratorContext context,
String typeName, String proxyTypeName) {
JClassType type = context.getTypeOracle().findType(typeName);
String packageName = type.getPackage().getName();
String className = type.getSimpleSourceName() + PROXY_SUFFIX;
String asyncName = typeName + ASYNC_SUFFIX;
String classNameExtendedServiceProxy = "com.google.appinventor.client.ExtendedServiceProxy";
// The generator can be invoked for the same class name more than once.
// In this case the GeneratorContext.tryCreate method will return null to
// indicate that the file already exists. This is not an error.
PrintWriter out = context.tryCreate(logger, packageName, className);
if (out != null) {
out.println("package " + packageName + ";");
out.println("class " + className);
out.println(" extends " + classNameExtendedServiceProxy + "<" + typeName + ">");
out.println(" implements " + ServiceDefTarget.class.getName() + ", " + asyncName + " {");
out.println(" private " + proxyTypeName + " proxy = new " + proxyTypeName + "();");
out.println(" public String getServiceEntryPoint() {");
out.println(" return proxy.getServiceEntryPoint();");
out.println(" }");
out.println(" public void setRpcRequestBuilder(" + RpcRequestBuilder.class.getName() +
" builder) {");
out.println(" proxy.setRpcRequestBuilder(builder);");
out.println(" }");
out.println(" public void setServiceEntryPoint(String address) {");
out.println(" proxy.setServiceEntryPoint(address);");
out.println(" }");
out.println(" public String getSerializationPolicyName() {");
out.println(" return proxy.getSerializationPolicyName();");
out.println(" }");
for (JMethod method : type.getMethods()) {
printMethod(out, method, typeName);
}
out.println("}");
context.commit(logger, out);
}
return packageName + "." + className;
}