public void setOwnerFactory(AutoBeanFactoryModel autoBeanFactoryModel) { if (autoBeanFactoryModel.getCategoryTypes() == null) { return; } StringBuilder sb = new StringBuilder(); for (JClassType category : autoBeanFactoryModel.getCategoryTypes()) { sb.append("_").append( category.getQualifiedSourceName().replace('.', '_')); } categorySuffix = sb.toString(); }
private void writeEnumSetup(SourceWriter sw) { for (Map.Entry<JEnumConstant, String> entry : model.getEnumTokenMap().entrySet()) { List<JEnumConstant> list = map.get(entry.getValue()); if (list == null) { for (Map.Entry<JEnumConstant, String> entry : model.getEnumTokenMap().entrySet()) {
categoryTypes = new ArrayList<JClassType>( categoryAnnotation.value().length); processClassArrayAnnotation(categoryAnnotation.value(), categoryTypes); } else { categoryTypes = null; NoWrap noWrapAnnotation = factoryType.getAnnotation(NoWrap.class); if (noWrapAnnotation != null) { processClassArrayAnnotation(noWrapAnnotation.value(), noWrapTypes); poison("The return type of method %s is a primitive type", method.getName()); continue; autoBeanInterface, returnType)[0]; if (beanType.isInterface() == null) { poison("The %s parameterization is not an interface", beanType.getQualifiedSourceName()); continue; toWrap = method.getParameters()[0].getType().isClassOrInterface(); if (!beanType.isAssignableFrom(toWrap)) { poison( "The %s parameterization %s is not assignable from the delegate" + " type %s", autoBeanInterface.getSimpleSourceName(), poison("Unexpecetd parameters in method %s", method.getName()); continue;
private AutoBeanType getAutoBeanType(JClassType beanType) { beanType = ModelUtils.ensureBaseType(beanType); AutoBeanType toReturn = peers.get(beanType); if (toReturn == null) { AutoBeanType.Builder builder = new AutoBeanType.Builder(); builder.setOwnerFactory(this); builder.setPeerType(beanType); builder.setMethods(computeMethods(beanType)); builder.setInterceptor(findInterceptor(beanType)); if (noWrapTypes != null) { for (JClassType noWrap : noWrapTypes) { if (noWrap.isAssignableFrom(beanType)) { builder.setNoWrap(true); break; } } } toReturn = builder.build(); peers.put(beanType, toReturn); } return toReturn; }
model = new AutoBeanFactoryModel(logger, toGenerate); factory.addImplementedInterface(typeName); SourceWriter sw = factory.createSourceWriter(context, pw); for (AutoBeanType type : model.getAllTypes()) { writeAutoBean(type);
maybeCalculate(classReturn); if (noWrapTypes != null) { for (JClassType noWrap : noWrapTypes) { builder.setAction(action); if (JBeanMethod.CALL.equals(action)) { JMethod staticImpl = findStaticImpl(beanType, method); if (staticImpl == null && objectMethods.contains(method)) { maybeCalculate(toAdd.getElementType()); } else if (toAdd.isMap()) { maybeCalculate(toAdd.getKeyType()); maybeCalculate(toAdd.getValueType());
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("}"); } }
.getCanonicalName()); sw.indent(); for (AutoBeanType type : model.getAllTypes()) { if (type.isNoWrap()) { continue; context.getTypeOracle().findType(AutoBeanFactory.class.getCanonicalName()) .getJNISignature(); for (AutoBeanType type : model.getAllTypes()) { String peerName = ModelUtils.ensureBaseType(type.getPeerType()).getQualifiedSourceName(); String peerJNIName = ModelUtils.ensureBaseType(type.getPeerType()).getJNISignature();
categoryTypes = new ArrayList<JClassType>( categoryAnnotation.value().length); processClassArrayAnnotation(categoryAnnotation.value(), categoryTypes); } else { categoryTypes = null; NoWrap noWrapAnnotation = factoryType.getAnnotation(NoWrap.class); if (noWrapAnnotation != null) { processClassArrayAnnotation(noWrapAnnotation.value(), noWrapTypes); poison("The return type of method %s is a primitive type", method.getName()); continue; autoBeanInterface, returnType)[0]; if (beanType.isInterface() == null) { poison("The %s parameterization is not an interface", beanType.getQualifiedSourceName()); continue; toWrap = method.getParameters()[0].getType().isClassOrInterface(); if (!beanType.isAssignableFrom(toWrap)) { poison( "The %s parameterization %s is not assignable from the delegate" + " type %s", autoBeanInterface.getSimpleSourceName(), poison("Unexpecetd parameters in method %s", method.getName()); continue;
private AutoBeanType getAutoBeanType(JClassType beanType) { beanType = ModelUtils.ensureBaseType(beanType); AutoBeanType toReturn = peers.get(beanType); if (toReturn == null) { AutoBeanType.Builder builder = new AutoBeanType.Builder(); builder.setOwnerFactory(this); builder.setPeerType(beanType); builder.setMethods(computeMethods(beanType)); builder.setInterceptor(findInterceptor(beanType)); if (noWrapTypes != null) { for (JClassType noWrap : noWrapTypes) { if (noWrap.isAssignableFrom(beanType)) { builder.setNoWrap(true); break; } } } toReturn = builder.build(); peers.put(beanType, toReturn); } return toReturn; }
model = new AutoBeanFactoryModel(logger, toGenerate); factory.addImplementedInterface(typeName); SourceWriter sw = factory.createSourceWriter(context, pw); for (AutoBeanType type : model.getAllTypes()) { writeAutoBean(type);
maybeCalculate(classReturn); if (noWrapTypes != null) { for (JClassType noWrap : noWrapTypes) { builder.setAction(action); if (JBeanMethod.CALL.equals(action)) { JMethod staticImpl = findStaticImpl(beanType, method); if (staticImpl == null && objectMethods.contains(method)) { maybeCalculate(toAdd.getElementType()); } else if (toAdd.isMap()) { maybeCalculate(toAdd.getKeyType()); maybeCalculate(toAdd.getValueType());
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("}"); } }
.getCanonicalName()); sw.indent(); for (AutoBeanType type : model.getAllTypes()) { if (type.isNoWrap()) { continue; context.getTypeOracle().findType(AutoBeanFactory.class.getCanonicalName()) .getJNISignature(); for (AutoBeanType type : model.getAllTypes()) { String peerName = ModelUtils.ensureBaseType(type.getPeerType()).getQualifiedSourceName(); String peerJNIName = ModelUtils.ensureBaseType(type.getPeerType()).getJNISignature();
public void setOwnerFactory(AutoBeanFactoryModel autoBeanFactoryModel) { if (autoBeanFactoryModel.getCategoryTypes() == null) { return; } StringBuilder sb = new StringBuilder(); for (JClassType category : autoBeanFactoryModel.getCategoryTypes()) { sb.append("_").append( category.getQualifiedSourceName().replace('.', '_')); } categorySuffix = sb.toString(); }
private void writeEnumSetup(SourceWriter sw) { for (Map.Entry<JEnumConstant, String> entry : model.getEnumTokenMap().entrySet()) { List<JEnumConstant> list = map.get(entry.getValue()); if (list == null) { for (Map.Entry<JEnumConstant, String> entry : model.getEnumTokenMap().entrySet()) {