private void writeMethods(SourceWriter sw) throws UnableToCompleteException { for (AutoBeanFactoryMethod method : model.getMethods()) { AutoBeanType autoBeanType = method.getAutoBeanType(); // public AutoBean<Foo> foo(FooSubtype wrapped) { sw.println("public %s %s(%s) {", method.getReturnType().getQualifiedSourceName(), method .getName(), method.isWrapper() ? (method.getWrappedType().getQualifiedSourceName() + " wrapped") : ""); if (method.isWrapper()) { sw.indent(); // AutoBean<Foo> toReturn = AutoBeanUtils.getAutoBean(wrapped); sw.println("%s toReturn = %s.getAutoBean(wrapped);", method.getReturnType() .getParameterizedQualifiedSourceName(), AutoBeanUtils.class.getCanonicalName()); sw.println("if (toReturn != null) {return toReturn;}"); // return new FooAutoBean(Factory.this, wrapped); sw.println("return new %s(%s.this, wrapped);", autoBeanType.getQualifiedSourceName(), simpleSourceName); sw.outdent(); } else { // return new FooAutoBean(Factory.this); sw.indentln("return new %s(%s.this);", autoBeanType.getQualifiedSourceName(), simpleSourceName); } sw.println("}"); } }
private void writeMethods(SourceWriter sw) throws UnableToCompleteException { for (AutoBeanFactoryMethod method : model.getMethods()) { AutoBeanType autoBeanType = method.getAutoBeanType(); // public AutoBean<Foo> foo(FooSubtype wrapped) { sw.println("public %s %s(%s) {", method.getReturnType().getQualifiedSourceName(), method .getName(), method.isWrapper() ? (method.getWrappedType().getQualifiedSourceName() + " wrapped") : ""); if (method.isWrapper()) { sw.indent(); // AutoBean<Foo> toReturn = AutoBeanUtils.getAutoBean(wrapped); sw.println("%s toReturn = %s.getAutoBean(wrapped);", method.getReturnType() .getParameterizedQualifiedSourceName(), AutoBeanUtils.class.getCanonicalName()); sw.println("if (toReturn != null) {return toReturn;}"); // return new FooAutoBean(Factory.this, wrapped); sw.println("return new %s(%s.this, wrapped);", autoBeanType.getQualifiedSourceName(), simpleSourceName); sw.outdent(); } else { // return new FooAutoBean(Factory.this); sw.indentln("return new %s(%s.this);", autoBeanType.getQualifiedSourceName(), simpleSourceName); } sw.println("}"); } }
sw.println("return ["); if (type.isSimpleBean()) { sw.indentln("@%s::new(%s),", type.getQualifiedSourceName(), factoryJNIName); } else { sw.indentln(","); sw.indentln("@%s::new(%s%s)", type.getQualifiedSourceName(), factoryJNIName, peerJNIName); sw.println("];"); sw.outdent();
sw.println("return ["); if (type.isSimpleBean()) { sw.indentln("@%s::new(%s),", type.getQualifiedSourceName(), factoryJNIName); } else { sw.indentln(","); sw.indentln("@%s::new(%s%s)", type.getQualifiedSourceName(), factoryJNIName, peerJNIName); sw.println("];"); sw.outdent();
sw.indent(); sw.println("private final %s data = %s.this.data;", Splittable.class.getCanonicalName(), type .getQualifiedSourceName()); for (AutoBeanMethod method : type.getMethods()) { JMethod jmethod = method.getMethod();
sw.indent(); sw.println("private final %s data = %s.this.data;", Splittable.class.getCanonicalName(), type .getQualifiedSourceName()); for (AutoBeanMethod method : type.getMethods()) { JMethod jmethod = method.getMethod();
private void writeReturnWrapper(SourceWriter sw, AutoBeanType type, AutoBeanMethod method) throws UnableToCompleteException { if (!method.isValueType() && !method.isNoWrap()) { JMethod jmethod = method.getMethod(); JClassType returnClass = jmethod.getReturnType().isClassOrInterface(); AutoBeanType peer = model.getPeer(returnClass); sw.println("if (toReturn != null) {"); sw.indent(); sw.println("if (%s.this.isWrapped(toReturn)) {", type.getSimpleSourceName()); sw.indentln("toReturn = %s.this.getFromWrapper(toReturn);", type.getSimpleSourceName()); sw.println("} else {"); sw.indent(); if (peer != null) { // toReturn = new FooAutoBean(getFactory(), toReturn).as(); sw.println("toReturn = new %s(getFactory(), toReturn).as();", peer.getQualifiedSourceName()); } sw.outdent(); sw.println("}"); sw.outdent(); sw.println("}"); } // Allow return values to be intercepted JMethod interceptor = type.getInterceptor(); if (interceptor != null) { // toReturn = FooCategory.__intercept(FooAutoBean.this, toReturn); sw.println("toReturn = %s.%s(%s.this, toReturn);", interceptor.getEnclosingType() .getQualifiedSourceName(), interceptor.getName(), type.getSimpleSourceName()); } }
private void writeReturnWrapper(SourceWriter sw, AutoBeanType type, AutoBeanMethod method) throws UnableToCompleteException { if (!method.isValueType() && !method.isNoWrap()) { JMethod jmethod = method.getMethod(); JClassType returnClass = jmethod.getReturnType().isClassOrInterface(); AutoBeanType peer = model.getPeer(returnClass); sw.println("if (toReturn != null) {"); sw.indent(); sw.println("if (%s.this.isWrapped(toReturn)) {", type.getSimpleSourceName()); sw.indentln("toReturn = %s.this.getFromWrapper(toReturn);", type.getSimpleSourceName()); sw.println("} else {"); sw.indent(); if (peer != null) { // toReturn = new FooAutoBean(getFactory(), toReturn).as(); sw.println("toReturn = new %s(getFactory(), toReturn).as();", peer.getQualifiedSourceName()); } sw.outdent(); sw.println("}"); sw.outdent(); sw.println("}"); } // Allow return values to be intercepted JMethod interceptor = type.getInterceptor(); if (interceptor != null) { // toReturn = FooCategory.__intercept(FooAutoBean.this, toReturn); sw.println("toReturn = %s.%s(%s.this, toReturn);", interceptor.getEnclosingType() .getQualifiedSourceName(), interceptor.getName(), type.getSimpleSourceName()); } }