/** * Adds a JEnumType to the AutoBeanMethod's enumMap so that the * AutoBeanFactoryGenerator can embed extra metadata about the enum values. */ private void processEnumType(JEnumType enumType) { Map<JEnumConstant, String> map = toReturn.enumMap; if (map == null) { map = toReturn.enumMap = new LinkedHashMap<JEnumConstant, String>(); } for (JEnumConstant e : enumType.getEnumConstants()) { String name = getEnumName(e); map.put(e, name); } } }
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; } } } }
if (toAdd.hasEnumMap()) { allEnumConstants.putAll(toAdd.getEnumMap()); if (toAdd.isCollection()) { maybeCalculate(toAdd.getElementType()); } else if (toAdd.isMap()) { maybeCalculate(toAdd.getKeyType()); maybeCalculate(toAdd.getValueType());
if (!method.getAction().equals(JBeanMethod.GET)) { continue; for (AutoBeanMethod maybeSetter : type.getMethods()) { boolean isASetter = maybeSetter.getAction().equals(JBeanMethod.SET) || maybeSetter.getAction().equals(JBeanMethod.SET_BUILDER); if (isASetter && maybeSetter.getPropertyName().equals(method.getPropertyName())) { setter = maybeSetter; break; .getCanonicalName(), AutoBeanUtils.class.getCanonicalName(), method.getMethod() .getName()); String visitMethod; String visitVariable = "bean"; if (method.isCollection()) { visitMethod = "Collection"; } else if (method.isMap()) { visitMethod = "Map"; } else if (method.isValueType()) { valueExpression = String.format("value = as.%s();", method.getMethod().getName()); visitMethod = "Value"; visitVariable = "value"; createTypeList(typeList, method.getMethod().getReturnType()); assert typeList.size() > 0; sw.println("%sMethodReference(as),", setter.getMethod().getName()); referencedSetters.add(setter);
.getQualifiedSourceName()); for (AutoBeanMethod method : type.getMethods()) { JMethod jmethod = method.getMethod(); JType returnType = jmethod.getReturnType(); sw.println("public %s {", getBaseMethodDeclaration(jmethod)); sw.indent(); switch (method.getAction()) { case GET: { String castType; .getSimpleSourceName(), method.getPropertyName()); Splittable.class.getCanonicalName()))) { sw.println("return data.isNull(\"%1$s\") ? null : data.get(\"%1$s\");", method .getPropertyName()); } else { .getSimpleSourceName(), method.getPropertyName()); .getPropertyName(), param.getName()); if (JBeanMethod.SET_BUILDER.equals(method.getAction())) { sw.println("return this;"); JMethod staticImpl = method.getStaticImpl(); if (!returnType.equals(JPrimitiveType.VOID)) { sw.print("return ");
assert asEnum != null; for (JEnumConstant value : asEnum.getEnumConstants()) { allEnumConstants.put(value, AutoBeanMethod.getEnumName(value)); beanType.getQualifiedSourceName()); for (AutoBeanMethod missing : autoBeanType.getMethods()) { if (missing.getAction().equals(JBeanMethod.CALL) && missing.getStaticImpl() == null) { poison(missing.getMethod().getReadableDeclaration());
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()); } }
if (toAdd.hasEnumMap()) { allEnumConstants.putAll(toAdd.getEnumMap()); if (toAdd.isCollection()) { maybeCalculate(toAdd.getElementType()); } else if (toAdd.isMap()) { maybeCalculate(toAdd.getKeyType()); maybeCalculate(toAdd.getValueType());
if (!method.getAction().equals(JBeanMethod.GET)) { continue; for (AutoBeanMethod maybeSetter : type.getMethods()) { boolean isASetter = maybeSetter.getAction().equals(JBeanMethod.SET) || maybeSetter.getAction().equals(JBeanMethod.SET_BUILDER); if (isASetter && maybeSetter.getPropertyName().equals(method.getPropertyName())) { setter = maybeSetter; break; .getCanonicalName(), AutoBeanUtils.class.getCanonicalName(), method.getMethod() .getName()); String visitMethod; String visitVariable = "bean"; if (method.isCollection()) { visitMethod = "Collection"; } else if (method.isMap()) { visitMethod = "Map"; } else if (method.isValueType()) { valueExpression = String.format("value = as.%s();", method.getMethod().getName()); visitMethod = "Value"; visitVariable = "value"; createTypeList(typeList, method.getMethod().getReturnType()); assert typeList.size() > 0; sw.println("%sMethodReference(as),", setter.getMethod().getName()); referencedSetters.add(setter);
.getQualifiedSourceName()); for (AutoBeanMethod method : type.getMethods()) { JMethod jmethod = method.getMethod(); JType returnType = jmethod.getReturnType(); sw.println("public %s {", getBaseMethodDeclaration(jmethod)); sw.indent(); switch (method.getAction()) { case GET: { String castType; .getSimpleSourceName(), method.getPropertyName()); Splittable.class.getCanonicalName()))) { sw.println("return data.isNull(\"%1$s\") ? null : data.get(\"%1$s\");", method .getPropertyName()); } else { .getSimpleSourceName(), method.getPropertyName()); .getPropertyName(), param.getName()); if (JBeanMethod.SET_BUILDER.equals(method.getAction())) { sw.println("return this;"); JMethod staticImpl = method.getStaticImpl(); if (!returnType.equals(JPrimitiveType.VOID)) { sw.print("return ");
assert asEnum != null; for (JEnumConstant value : asEnum.getEnumConstants()) { allEnumConstants.put(value, AutoBeanMethod.getEnumName(value)); beanType.getQualifiedSourceName()); for (AutoBeanMethod missing : autoBeanType.getMethods()) { if (missing.getAction().equals(JBeanMethod.CALL) && missing.getStaticImpl() == null) { poison(missing.getMethod().getReadableDeclaration());
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()); } }
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; } } } }
/** * Adds a JEnumType to the AutoBeanMethod's enumMap so that the * AutoBeanFactoryGenerator can embed extra metadata about the enum values. */ private void processEnumType(JEnumType enumType) { Map<JEnumConstant, String> map = toReturn.enumMap; if (map == null) { map = toReturn.enumMap = new LinkedHashMap<JEnumConstant, String>(); } for (JEnumConstant e : enumType.getEnumConstants()) { String name = getEnumName(e); map.put(e, name); } } }
sw.indent(); for (AutoBeanMethod method : type.getMethods()) { JMethod jmethod = method.getMethod(); String methodName = jmethod.getName(); JParameter[] parameters = jmethod.getParameters(); sw.indent(); switch (method.getAction()) { case GET: if (JBeanMethod.SET_BUILDER.equals(method.getAction())) { sw.println("return this;");
sw.indent(); for (AutoBeanMethod method : type.getMethods()) { JMethod jmethod = method.getMethod(); String methodName = jmethod.getName(); JParameter[] parameters = jmethod.getParameters(); sw.indent(); switch (method.getAction()) { case GET: if (JBeanMethod.SET_BUILDER.equals(method.getAction())) { sw.println("return this;");