List of usage examples for com.google.gwt.core.ext.typeinfo JClassType getInheritableMethods
JMethod[] getInheritableMethods();
From source file:cc.alcina.framework.entity.gwtsynth.ClientReflectionGenerator.java
License:Apache License
private List<JMethod> getPropertyGetters(JClassType jct) { ArrayList<JMethod> methods = new ArrayList<JMethod>(); JMethod[] jms = jct.getInheritableMethods(); for (JMethod jm : jms) { String name = jm.getName(); if ((name.startsWith("get") && name.length() > 3) || (name.startsWith("is") && name.length() > 2)) { if (jm.getParameters().length == 0) { methods.add(jm);/*w w w. j av a2 s. co m*/ } } } return methods; }
From source file:com.cgxlib.xq.rebind.JsonBuilderGenerator.java
License:Apache License
public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String requestedClass) throws UnableToCompleteException { oracle = generatorContext.getTypeOracle(); JClassType clazz = oracle.findType(requestedClass); jsonBuilderType = oracle.findType(JsonBuilder.class.getName()); settingsType = oracle.findType(IsProperties.class.getName()); stringType = oracle.findType(String.class.getName()); jsType = oracle.findType(JavaScriptObject.class.getName()); listType = oracle.findType(List.class.getName()); functionType = oracle.findType(Function.class.getName()); jsonFactoryType = oracle.findType(JsonFactory.class.getName()); String t[] = generateClassName(clazz); boolean isFactory = clazz.isAssignableTo(jsonFactoryType); SourceWriter sw = getSourceWriter(treeLogger, generatorContext, t[0], t[1], isFactory, requestedClass); if (sw != null) { if (isFactory) { generateCreateMethod(sw, treeLogger); } else {// w w w .j a va 2 s .co m Set<String> attrs = new HashSet<String>(); for (JMethod method : clazz.getInheritableMethods()) { String methName = method.getName(); // skip method from JsonBuilder if (jsonBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null || settingsType.findMethod(method.getName(), method.getParameterTypes()) != null) { continue; } Name nameAnnotation = method.getAnnotation(Name.class); String name = nameAnnotation != null ? nameAnnotation.value() : methName.replaceFirst("^(get|set)", ""); if (nameAnnotation == null) { name = name.substring(0, 1).toLowerCase() + name.substring(1); } attrs.add(name); generateMethod(sw, method, name, treeLogger); } generateFieldNamesMethod(sw, attrs, treeLogger); generateToJsonMethod(sw, t[3], treeLogger); } sw.commit(treeLogger); } return t[2]; }
From source file:com.cgxlib.xq.rebind.SelectorGeneratorBase.java
License:Apache License
public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String requestedClass) throws UnableToCompleteException { this.treeLogger = treeLogger; TypeOracle oracle = generatorContext.getTypeOracle(); nodeType = oracle.findType("com.google.gwt.dom.client.Node"); JClassType selectorType = oracle.findType(requestedClass); String generatedPkgName = selectorType.getPackage().getName(); String generatedClassName = selectorType.getName().replace('.', '_') + "_" + getImplSuffix(); SourceWriter sw = getSourceWriter(treeLogger, generatorContext, generatedPkgName, generatedClassName, requestedClass);//from w ww . jav a2 s . c om if (sw != null) { for (JMethod method : selectorType.getInheritableMethods()) { generateMethod(sw, method, treeLogger); } genGetAllMethod(sw, selectorType.getInheritableMethods(), treeLogger); sw.commit(treeLogger); } return generatedPkgName + "." + generatedClassName; }
From source file:com.cgxlib.xq.rebind.XmlBuilderGenerator.java
License:Apache License
public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String requestedClass) throws UnableToCompleteException { oracle = generatorContext.getTypeOracle(); JClassType clazz = oracle.findType(requestedClass); xmlBuilderType = oracle.findType(XmlBuilder.class.getName()); stringType = oracle.findType(String.class.getName()); String t[] = generateClassName(clazz); SourceWriter sw = getSourceWriter(treeLogger, generatorContext, t[0], t[1], requestedClass); if (sw != null) { for (JMethod method : clazz.getInheritableMethods()) { // skip method from JsonBuilder if (xmlBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null) { continue; }/*from w w w . j ava 2s. co m*/ generateMethod(sw, method, treeLogger); } sw.commit(treeLogger); } return t[2]; }
From source file:com.colinalworth.gwt.websockets.rebind.ServerCreator.java
License:Apache License
public void create(TreeLogger logger, GeneratorContext context) throws UnableToCompleteException { String typeName = this.serverType.getQualifiedSourceName(); String packageName = getPackageName(); String simpleName = getSimpleName(); TypeOracle oracle = context.getTypeOracle(); PrintWriter pw = context.tryCreate(logger, packageName, simpleName); if (pw == null) { return;/* ww w . j av a 2s. c om*/ } JClassType serverType = oracle.findType(Name.getSourceNameForClass(Server.class)); JClassType clientType = ModelUtils.findParameterizationOf(serverType, this.serverType)[1]; ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(packageName, simpleName); factory.setSuperclass(Name.getSourceNameForClass(ServerImpl.class) + "<" + typeName + "," + clientType.getQualifiedSourceName() + ">"); factory.addImplementedInterface(typeName); SourceWriter sw = factory.createSourceWriter(context, pw); //TODO move this check before the printwriter creation can fail, and allow the warn to be optional sw.println("public %1$s(%2$s errorHandler) {", simpleName, Name.getSourceNameForClass(ServerBuilder.ConnectionErrorHandler.class)); RemoteServiceRelativePath path = this.serverType.getAnnotation(RemoteServiceRelativePath.class); if (path == null) { // logger.log(Type.WARN, "@RemoteServiceRelativePath required on " + typeName + " to make a connection to the server without a ServerBuilder"); // throw new UnableToCompleteException(); sw.indentln("super(null);"); sw.indentln( "throw new RuntimeException(\"@RemoteServiceRelativePath annotation required on %1$s to make a connection without a path defined in ServerBuilder\");"); } else { sw.indentln("super(errorHandler, " + "com.google.gwt.user.client.Window.Location.getProtocol().toLowerCase().startsWith(\"https\") ? \"wss://\": \"ws://\", " + "com.google.gwt.user.client.Window.Location.getHost(), \"%1$s\");", path.value()); } sw.println("}"); sw.println("public %1$s(%2$s errorHandler, String url) {", simpleName, Name.getSourceNameForClass(ServerBuilder.ConnectionErrorHandler.class)); sw.indentln("super(errorHandler, url);"); sw.println("}"); //Find all types that may go over the wire // Collect the types the server will send to the client using the Client interface SerializableTypeOracleBuilder serverSerializerBuilder = new SerializableTypeOracleBuilder(logger, context); appendMethodParameters(logger, clientType, Client.class, serverSerializerBuilder); // Also add the wrapper object ClientInvocation serverSerializerBuilder.addRootType(logger, oracle.findType(ClientInvocation.class.getName())); serverSerializerBuilder.addRootType(logger, oracle.findType(ClientCallbackInvocation.class.getName())); // Collect the types the client will send to the server using the Server interface SerializableTypeOracleBuilder clientSerializerBuilder = new SerializableTypeOracleBuilder(logger, context); appendMethodParameters(logger, this.serverType, Server.class, clientSerializerBuilder); // Also add the ServerInvocation wrapper clientSerializerBuilder.addRootType(logger, oracle.findType(ServerInvocation.class.getName())); clientSerializerBuilder.addRootType(logger, oracle.findType(ServerCallbackInvocation.class.getName())); String tsName = simpleName + "_TypeSerializer"; TypeSerializerCreator serializerCreator = new TypeSerializerCreator(logger, clientSerializerBuilder.build(logger), serverSerializerBuilder.build(logger), context, packageName + "." + tsName, tsName); serializerCreator.realize(logger); // Make the newly created Serializer available at runtime sw.println("protected %1$s __getSerializer() {", Serializer.class.getName()); sw.indentln("return %2$s.<%1$s>create(%1$s.class);", tsName, GWT.class.getName()); sw.println("}"); // Build methods that call from the client to the server for (JMethod m : this.serverType.getInheritableMethods()) { if (isRemoteMethod(m, Server.class)) { printServerMethodBody(logger, context, sw, m); } } // Read incoming calls and dispatch them to the correct client method sw.println("protected void __invoke(String method, Object[] params) {"); for (JMethod m : clientType.getInheritableMethods()) { if (isRemoteMethod(m, Client.class)) { JParameter[] params = m.getParameters(); sw.println("if (method.equals(\"%1$s\") && params.length == %2$d) {", m.getName(), params.length); sw.indent(); sw.println("getClient().%1$s(", m.getName()); sw.indent(); for (int i = 0; i < params.length; i++) { if (i != 0) { sw.print(","); } sw.println("(%1$s)params[%2$d]", params[i].getType().getQualifiedSourceName(), i); } sw.outdent(); sw.println(");"); sw.outdent(); sw.println("}"); } } sw.println("}"); sw.println("protected void __onError(Exception error) {"); sw.println("}"); sw.commit(logger); }
From source file:com.ekuefler.supereventbus.rebind.EventRegistrationWriter.java
License:Apache License
/** * Writes the source for getMethods() the given target class to the given writer. *///from www . java 2 s . co m void writeGetMethods(JClassType target, SourceWriter writer) throws UnableToCompleteException { String targetType = target.getQualifiedSourceName(); writer.println("public List<EventHandlerMethod<%s, ?>> getMethods() {", targetType); writer.indent(); // Write a list that we will add all handlers to before returning writer.println("List<%1$s> methods = new LinkedList<%1$s>();", String.format("EventHandlerMethod<%s, ?>", targetType)); // Iterate over each method in the target, looking for methods annotated with @Subscribe for (JMethod method : target.getInheritableMethods()) { if (method.getAnnotation(Subscribe.class) == null) { continue; } checkValidity(target, method); // Generate a list of types that should be handled by this method. Normally, this is a single // type equal to the method's first argument. If the argument in a MultiEvent, this list of // types comes from the @EventTypes annotation on the parameter. final List<String> paramTypes = new LinkedList<String>(); final boolean isMultiEvent; if (getFirstParameterType(method).equals(MultiEvent.class.getCanonicalName())) { isMultiEvent = true; for (Class<?> type : method.getParameters()[0].getAnnotation(EventTypes.class).value()) { paramTypes.add(type.getCanonicalName()); } } else { isMultiEvent = false; paramTypes.add(getFirstParameterType(method)); } // Add an implementation of EventHandlerMethod to the list for each type this method handles for (String paramType : paramTypes) { writer.println("methods.add(new EventHandlerMethod<%s, %s>() {", targetType, paramType); writer.indent(); { // Implement invoke() by calling the method, first checking filters if provided writer.println("public void invoke(%s instance, %s arg) {", targetType, paramType); String invocation = String.format( isMultiEvent ? "instance.%s(new MultiEvent(arg));" : "instance.%s(arg);", method.getName()); if (method.getAnnotation(When.class) != null) { writer.indentln("if (%s) { %s }", getFilter(method), invocation); } else { writer.indentln(invocation); } writer.println("}"); // Implement acceptsArgument using instanceof writer.println("public boolean acceptsArgument(Object arg) {"); writer.indentln("return arg instanceof %s;", paramType); writer.println("}"); // Implement getDispatchOrder as the inverse of the method's priority writer.println("public int getDispatchOrder() {"); writer.indentln("return %d;", method.getAnnotation(WithPriority.class) != null ? -method.getAnnotation(WithPriority.class).value() : 0); writer.println("}"); } writer.outdent(); writer.println("});"); } } // Return the list of EventHandlerMethods writer.println("return methods;"); writer.outdent(); writer.println("}"); }
From source file:com.gafactory.core.rebind.ValueProviderCreator.java
License:sencha.com license
protected JMethod getMethod(JClassType type, String methodName) { JMethod[] methods = type.getInheritableMethods(); for (JMethod m : methods) { if (m.getName().equals(methodName)) { return m; }//w ww. java 2s . com } return null; }
From source file:com.github.gilbertotorrezan.gwtviews.rebind.PresenterGenerator.java
License:Open Source License
private String getInjectorMethod(TreeLogger logger, JClassType injector, String injectorMethod, String className) throws UnableToCompleteException { if (injectorMethod != null && !injectorMethod.isEmpty()) { try {//from ww w. j a v a 2 s. com injector.getMethod(injectorMethod, new JType[0]); } catch (NotFoundException e) { logger.log(Type.WARN, "The injector method \"" + injectorMethod + "\" was not found on class " + injector.getQualifiedSourceName()); //a compiler error will be trigged if the method really doesn't exist } return injectorMethod; } else { String methodName = null; JMethod[] methods = injector.getInheritableMethods(); for (JMethod method : methods) { JType returnType = method.getReturnType(); if (returnType.getQualifiedSourceName().equals(className)) { if (methodName != null) { logger.log(Type.ERROR, "The injector " + injector.getName() + " has more than one method with " + className + " as return type. Use the \"injectorMethod\" property to specify which one should be used."); throw new UnableToCompleteException(); } methodName = method.getName(); } } if (methodName == null) { logger.log(Type.INFO, "The injector " + injector.getName() + " has no methods with " + className + " as return type. The View will not be injected."); return null; } return methodName; } }
From source file:com.github.ludorival.dao.gwt.rebind.EntityManagerGenerator.java
License:Apache License
private BeanMetadata create(GeneratorContext context, TreeLogger logger, String packageName, JClassType type, Class<?> classAdapter, IsEntity anno) throws TypeOracleException { String beanName = anno == null || anno.aliasName().isEmpty() ? type.getName() : anno.aliasName(); Source implementation = null; JClassType implType = type;//from w w w .j a v a 2 s . c o m TypeOracle typeOracle = context.getTypeOracle(); if (type.isInterface() != null) { implType = null; JClassType[] types = type.getSubtypes(); log(logger, Type.DEBUG, "Get all sub types of %s : %s", type, Arrays.toString(types)); if (types != null && types.length > 0) { for (JClassType jClassType : types) { if (isInstantiable(jClassType, logger)) { implType = jClassType; implementation = new Source(implType.getPackage().getName(), implType.getName()); break; } } } if (implType == null) { log(logger, Type.ERROR, "The type %s has not valid subtypes " + "%s !", type, Arrays.toString(types)); return null; } } if (!implType.isDefaultInstantiable()) return null; String prefix = classAdapter.getSimpleName().replace("Adapter", ""); boolean isEntity = anno != null; String className = prefix + beanName; if (parseOnlyInterface && implType != type) className += "Light"; PrintWriter writer = context.tryCreate(logger, packageName, className); if (writer == null) { return new BeanMetadata(type, className, implementation, isEntity); } ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(packageName, className); logger.log(Type.DEBUG, "Create Entity " + factory.getCreatedClassName()); factory.setSuperclass(classAdapter.getSimpleName() + "<" + type.getName() + ">"); factory.addImport(RuntimeException.class.getName()); factory.addImport(classAdapter.getName()); factory.addImport(type.getQualifiedSourceName()); if (isEntity) { factory.addImport(ArrayList.class.getName()); factory.addImport(Collection.class.getName()); } factory.addImport(HashMap.class.getName()); factory.addImport(Property.class.getName()); factory.addImport(Property.class.getName() + ".Kind"); factory.addImport(Index.class.getName()); factory.addImport(implType.getQualifiedSourceName()); factory.addImport("javax.annotation.Generated"); factory.addAnnotationDeclaration("@Generated(" + "value=\"" + AdapterEntity.class.getName() + "\", " + "date=\"" + new Date() + "\", " + "comments=\"Generated by DAO-GWT project.\")"); SourceWriter sourceWriter = factory.createSourceWriter(context, writer); sourceWriter.println("//AUTO GENERATED FILE BY DAO-GWT " + getClass().getName() + ". DO NOT EDIT!\n"); sourceWriter.println("private static HashMap<String,Property<%s,?>> PROPERTIES = " + "new HashMap<String,Property<%s,?>>();", type.getName(), type.getName()); if (isEntity) { factory.addImport(ArrayList.class.getName()); factory.addImport(Index.class.getName()); sourceWriter.println("private static Collection<Index> INDEXES = " + "new ArrayList<Index>();"); } sourceWriter.println("static {"); sourceWriter.indent(); JClassType interfaz = type != implType ? type : null; JMethod[] methods = parseOnlyInterface ? type.getInheritableMethods() : implType.getInheritableMethods(); for (JMethod method : methods) { String name = method.getName(); //Check if the method has a IsIgnored annotation before to continue IsIgnored ignored = method.getAnnotation(IsIgnored.class); if (ignored != null) { log(logger, Type.DEBUG, EXPLICITELY_IGNORED, name, implType); continue; } boolean startsWithGet = name.startsWith("get"); boolean startsWithIs = name.startsWith("is"); if (!startsWithGet && !startsWithIs) { log(logger, Type.DEBUG, IGNORE_METHOD, name, implType); continue; } //check no parameters if (method.getParameterTypes().length != 0) { log(logger, Type.WARN, NO_PARAMETER_GETTER, name, implType); continue; } //check return type JType returnType = method.getReturnType(); if (returnType == null || returnType.getQualifiedSourceName().equals(Void.class.getName()) || returnType.getQualifiedSourceName().equals(void.class.getName())) { log(logger, Type.DEBUG, VOID_GETTER, name + "" + returnType, implType); continue; } //change the format of the name getXyy ==> xyy String getterSetter = name; if (startsWithGet) getterSetter = name.substring(3); else if (startsWithIs) getterSetter = name.substring(2); name = getterSetter.substring(0, 1).toLowerCase() + getterSetter.substring(1); // check if the getter has an annotation IsIndexable indexable = method.getAnnotation(IsIndexable.class); boolean isIndexable = indexable != null; if (isIndexable && !isEntity) log(logger, Type.WARN, ONLY_ENTITY_FOR_INDEX, name, implType, IsEntity.class); isIndexable = isIndexable && isEntity;//only entity can defined indexable element String indexName = isIndexable ? indexable.aliasName() : ""; String[] compositeIndexes = isIndexable ? indexable.compoundWith() : new String[0]; Kind kind = null; JType typeOfCollection = null; String typeOfCollectionString = "null"; if (!isPrimitive(returnType)) { //load complex properties except Key if (returnType.isEnum() != null) { kind = Kind.ENUM; } else { boolean isPrimitive = false; boolean isEnum = false; JParameterizedType pType = returnType.isParameterized(); JType collection = typeOracle.parse(Collection.class.getName()); if (pType != null && pType.getRawType().isAssignableTo(collection.isClassOrInterface())) { JClassType[] types = pType.getTypeArgs(); kind = Kind.COLLECTION_OF_PRIMITIVES; if (types.length > 1) { log(logger, Type.DEBUG, CANNOT_PROCESS_PARAMETERIZED_TYPE, returnType, implType); continue; } typeOfCollection = types[0]; typeOfCollectionString = typeOfCollection.getQualifiedSourceName() + ".class"; log(logger, Type.DEBUG, "The type of the collection is %s", typeOfCollectionString); isPrimitive = isPrimitive(typeOfCollection); isEnum = typeOfCollection.isEnum() != null; } if (!isPrimitive) { if (isEnum && kind != null) { kind = Kind.COLLECTION_OF_ENUMS; } else { JClassType classType = typeOfCollection != null ? typeOfCollection.isClassOrInterface() : returnType.isClassOrInterface(); boolean isBean = isBean(classType); if (isBean) { log(logger, Type.DEBUG, "The property %s is well a type %s", name, classType); if (kind == null) kind = Kind.BEAN; else kind = Kind.COLLECTION_OF_BEANS; } else { log(logger, Type.DEBUG, "The property %s has not a bean type %s", name, classType); continue; } } } } } assert kind != null; boolean isMemo = method.getAnnotation(IsMemo.class) != null; String oldName = "null"; OldName oldNameAnno = method.getAnnotation(OldName.class); if (oldNameAnno != null) oldName = "\"" + oldNameAnno.value() + "\""; //create a property if (kind == Kind.BEAN || kind == Kind.COLLECTION_OF_BEANS) factory.addImport(returnType.getQualifiedSourceName()); String valueType = ""; JClassType classType = returnType.isClassOrInterface(); JPrimitiveType primitiveType = returnType.isPrimitive(); if (classType != null) valueType = classType.getQualifiedSourceName(); else if (primitiveType != null) { valueType = primitiveType.getQualifiedBoxedSourceName(); } sourceWriter.println("{ //Property %s", name); sourceWriter.indent(); sourceWriter.print("Index index ="); if (isIndexable) { if (indexName.isEmpty()) indexName = name; sourceWriter.println("new Index(\"%s\",\"%s\",new String[]{%s});", indexName, name, String.join(",", compositeIndexes)); } else sourceWriter.println("null;"); boolean useKeyAsString = anno != null ? (name.equals(anno.keyName()) ? anno.useKeyAsString() : false) : false; KeyOf keyOf = method.getAnnotation(KeyOf.class); if (keyOf != null) { IsEntity isEntity2 = keyOf.entity().getAnnotation(IsEntity.class); if (isEntity2 == null) { log(logger, Type.ERROR, AdapterEntityManager.KEY_OF_NO_ENTITY, method, keyOf, keyOf.entity(), IsEntity.class); continue; } useKeyAsString = isEntity2.useKeyAsString(); } boolean isHidden = isHidden(method, interfaz); sourceWriter.println( "Property<%s,%s> property = new Property<%s,%s>(\"%s\",%s,%s.class,%s,%s,%s,%s,index,%s){", type.getName(), valueType, type.getName(), valueType, name, oldName, returnType.getQualifiedSourceName(), typeOfCollectionString, kind != null ? "Kind." + kind.name() : "null", useKeyAsString + "", isMemo + "", isHidden + ""); sourceWriter.indent(); sourceWriter.println("@Override"); sourceWriter.println("public %s get(%s instance){", valueType, type.getName()); sourceWriter.indent(); sourceWriter.println("return ((%s)instance).%s();", implType.getName(), startsWithGet ? "get" + getterSetter : "is" + getterSetter); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println("@Override"); sourceWriter.println("public void set(%s instance, %s value){", type.getName(), valueType); sourceWriter.indent(); if (getSetter(implType, getterSetter, returnType) != null) sourceWriter.println("((%s)instance).%s(value);", implType.getName(), "set" + getterSetter); else { logger.log(Type.WARN, " Not found setter for " + getterSetter); sourceWriter.println("throw new RuntimeException(\"No such setter " + getterSetter + " \");"); } sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.outdent(); sourceWriter.println("};"); sourceWriter.println("PROPERTIES.put(\"%s\",property);", name); if (!oldName.equals("null")) { sourceWriter.println("PROPERTIES.put(%s,property);", oldName); } if (isIndexable) sourceWriter.println("INDEXES.add(index);"); sourceWriter.outdent(); sourceWriter.println("}"); log(logger, Type.DEBUG, SUCCESSFUL_ADD_PROPERTY, name + ":" + valueType, implType); } sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println(); sourceWriter.println("public %s(){", className); sourceWriter.indent(); /* * boolean asyncReady, boolean autoGeneratedFlag, String keyName, boolean useKeyAsString, Class<T> type,Class<? extends T> implType, Map<String, Property<T,?>> mapAllProperties, Collection<Index> indexes) { super(type,implType,mapAllProperties); */ if (isEntity) sourceWriter .println(String.format("super(\"%s\",%s,%s,\"%s\",%s,%s.class,%s.class,PROPERTIES,INDEXES);", anno.aliasName().isEmpty() ? type.getName() : anno.aliasName(), anno.asyncReady(), anno.autoGeneratedKey(), anno.keyName(), anno.useKeyAsString(), type.getName(), implType.getName())); else { sourceWriter.println( String.format("super(%s.class,%s.class,PROPERTIES);", type.getName(), implType.getName())); } sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.println(); sourceWriter.println("@Override"); sourceWriter.println("public %s newInstance(){", type.getName()); sourceWriter.indent(); sourceWriter.println("return new %s();", implType.getName()); sourceWriter.outdent(); sourceWriter.println("}"); sourceWriter.outdent(); sourceWriter.println("}"); context.commit(logger, writer); return new BeanMetadata(type, className, implementation, isEntity); }
From source file:com.google.web.bindery.autobean.gwt.rebind.model.AutoBeanFactoryModel.java
License:Apache License
private List<AutoBeanMethod> computeMethods(JClassType beanType) { List<JMethod> toExamine = new ArrayList<JMethod>(); toExamine.addAll(Arrays.asList(beanType.getInheritableMethods())); toExamine.addAll(objectMethods);/*from ww w .java2 s .co m*/ List<AutoBeanMethod> toReturn = new ArrayList<AutoBeanMethod>(toExamine.size()); for (JMethod method : toExamine) { if (method.isPrivate()) { // Ignore private methods continue; } AutoBeanMethod.Builder builder = new AutoBeanMethod.Builder(); builder.setMethod(method); // See if this method shouldn't have its return type wrapped // TODO: Allow class return types? JClassType classReturn = method.getReturnType().isInterface(); if (classReturn != null) { maybeCalculate(classReturn); if (noWrapTypes != null) { for (JClassType noWrap : noWrapTypes) { if (noWrap.isAssignableFrom(classReturn)) { builder.setNoWrap(true); break; } } } } // GET, SET, or CALL JBeanMethod action = JBeanMethod.which(method); builder.setAction(action); if (JBeanMethod.CALL.equals(action)) { JMethod staticImpl = findStaticImpl(beanType, method); if (staticImpl == null && objectMethods.contains(method)) { // Don't complain about lack of implementation for Object methods continue; } builder.setStaticImp(staticImpl); } AutoBeanMethod toAdd = builder.build(); // Collect referenced enums if (toAdd.hasEnumMap()) { allEnumConstants.putAll(toAdd.getEnumMap()); } // See if parameterizations will pull in more types if (toAdd.isCollection()) { maybeCalculate(toAdd.getElementType()); } else if (toAdd.isMap()) { maybeCalculate(toAdd.getKeyType()); maybeCalculate(toAdd.getValueType()); } toReturn.add(toAdd); } return toReturn; }