public String getQualifiedSourceName() { return getPackageNome() + "." + getSimpleSourceName(); }
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("}"); } }
public void setMethods(List<AutoBeanMethod> methods) { toReturn.methods = new ArrayList<AutoBeanMethod>(methods); Collections.sort(toReturn.methods, new Comparator<AutoBeanMethod>() { public int compare(AutoBeanMethod o1, AutoBeanMethod o2) { int c = o1.getAction().compareTo(o2.getAction()); if (c != 0) { return c; } // Name alone would cause overload conflicts return o1.getMethod().getReadableDeclaration().compareTo( o2.getMethod().getReadableDeclaration()); } }); toReturn.methods = Collections.unmodifiableList(toReturn.methods); toReturn.simpleBean = true; for (AutoBeanMethod method : methods) { if (method.getAction().equals(JBeanMethod.CALL)) { if (method.getStaticImpl() == null) { toReturn.simpleBean = false; } else { affectedByCategories = true; } } } }
public void setMethod(JMethod method) { setName(method.getName()); setReturnType(method.getReturnType().isClassOrInterface()); if (method.getParameters().length == 1) { setWrappedType(method.getParameters()[0].getType().isClassOrInterface()); } }
@Override public String inferName(JMethod method) { if (isBooleanProperty(method) && method.getName().startsWith(IS_PREFIX)) { return Introspector.decapitalize(method.getName().substring(2)); } return super.inferName(method); }
/** * Call {@link #processEnumType(JEnumType)} if {@code type} is a * {@link JEnumType}. */ private void maybeProcessEnumType(JType type) { assert type != null : "type == null"; JEnumType enumType = type.isEnum(); if (enumType != null) { processEnumType(enumType); } }
private void die(String message) throws UnableToCompleteException { poison(message); throw new UnableToCompleteException(); }
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(); }
@Override public boolean matches(JMethod method) { if (method.getParameters().length > 0) { return false; } if (isBooleanProperty(method)) { return true; } String name = method.getName(); if (name.startsWith(GET_PREFIX) && name.length() > 3) { return true; } return false; }
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("}"); } }
public void setMethods(List<AutoBeanMethod> methods) { toReturn.methods = new ArrayList<AutoBeanMethod>(methods); Collections.sort(toReturn.methods, new Comparator<AutoBeanMethod>() { public int compare(AutoBeanMethod o1, AutoBeanMethod o2) { int c = o1.getAction().compareTo(o2.getAction()); if (c != 0) { return c; } // Name alone would cause overload conflicts return o1.getMethod().getReadableDeclaration().compareTo( o2.getMethod().getReadableDeclaration()); } }); toReturn.methods = Collections.unmodifiableList(toReturn.methods); toReturn.simpleBean = true; for (AutoBeanMethod method : methods) { if (method.getAction().equals(JBeanMethod.CALL)) { if (method.getStaticImpl() == null) { toReturn.simpleBean = false; } else { affectedByCategories = true; } } } }
public void setMethod(JMethod method) { setName(method.getName()); setReturnType(method.getReturnType().isClassOrInterface()); if (method.getParameters().length == 1) { setWrappedType(method.getParameters()[0].getType().isClassOrInterface()); } }
public String getQualifiedSourceName() { return getPackageNome() + "." + getSimpleSourceName(); }
@Override public String inferName(JMethod method) { if (isBooleanProperty(method) && method.getName().startsWith(IS_PREFIX)) { return Introspector.decapitalize(method.getName().substring(2)); } return super.inferName(method); }
/** * Call {@link #processEnumType(JEnumType)} if {@code type} is a * {@link JEnumType}. */ private void maybeProcessEnumType(JType type) { assert type != null : "type == null"; JEnumType enumType = type.isEnum(); if (enumType != null) { processEnumType(enumType); } }
private void die(String message) throws UnableToCompleteException { poison(message); throw new UnableToCompleteException(); }