private org.eclipse.jdt.core.dom.Type parseTypeBound(String bound) { String stub = "public class Stub<T extends " + bound + "> {}"; JavaClassSource temp = Roaster.parse(JavaClassSource.class, stub); TypeParameter v = (TypeParameter) temp.getTypeVariables().get(0).getInternal(); return (org.eclipse.jdt.core.dom.Type) v.typeBounds().get(0); } }
private org.eclipse.jdt.core.dom.Type parseTypeBound(String bound) { String stub = "public class Stub<T extends " + bound + "> {}"; JavaClassSource temp = Roaster.parse(JavaClassSource.class, stub); TypeParameter v = (TypeParameter) temp.getTypeVariables().get(0).getInternal(); return (org.eclipse.jdt.core.dom.Type) v.typeBounds().get(0); } }
private org.eclipse.jdt.core.dom.Type parseTypeBound(String bound) { String stub = "public class Stub<T extends " + bound + "> {}"; JavaClassSource temp = Roaster.parse(JavaClassSource.class, stub); TypeParameter v = (TypeParameter) temp.getTypeVariables().get(0).getInternal(); return (org.eclipse.jdt.core.dom.Type) v.typeBounds().get(0); } }
private void writeMapRemove(final JavaClassSource javaClass, final Property propDef) { final String name = "remove" + propDef.getPropertyName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); body = Templates.use(TemplateName.PropertyRemoveMap, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeMapPut(final JavaClassSource javaClass, final Property propDef) { final String name = "put" + propDef.getPropertyName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); body = Templates.use(TemplateName.PropertyPutMap, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeListRemove(final JavaClassSource javaClass, final Property propDef) { final String name = "remove" + propDef.getUpperName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); javaClass.addImport("java.util.Arrays"); body = Templates.use(TemplateName.PropertyRemoveList, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.addParameter(propDef.subtype(), propDef.name()).setVarArgs(true); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeListAdd(final JavaClassSource javaClass, final Property propDef) { final String name = "add" + propDef.getUpperName(); if (!javaClass.hasMethodSignature(name)) { final StringBuilder javadoc = new StringBuilder(); javadoc .append("@return the pSourcePath\n"); String body = ""; javaClass.addImport("javafx.collections.FXCollections"); javaClass.addImport("java.util.Arrays"); body = Templates.use(TemplateName.PropertyAddList, propDef); final MethodSource<?> method = javaClass.addMethod() .setName(name) .setPublic() .setBody(body.toString()) .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.addParameter(propDef.subtype(), propDef.name()).setVarArgs(true); method.getJavaDoc().setFullText(javadoc.toString()); } else { // javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod(propDef.getName()).getBody() // + body.toString()); } }
private void writeSetter(final JavaClassSource javaClass, final Property propDef) { if (propDef.needSetter()) { // if (!javaClass.hasMethodSignature(propDef.getName())) { // final StringBuilder javadoc = new StringBuilder(); // javadoc // .append("@return the sourcePath\n"); String body = ""; if (propDef.isList()) { body = Templates.use(TemplateName.Setter_List, propDef); } else if (propDef.isMap()) { body = Templates.use(TemplateName.Setter_Map, propDef); } else { body = Templates.use(TemplateName.Setter, propDef); } final MethodSource<?> method = javaClass.addMethod() .setName(propDef.name()) .setPublic() .setBody(body) // .setReturnTypeVoid(); .setReturnType(javaClass.getTypeVariables().isEmpty() ? javaClass.getName() : javaClass.getTypeVariables().get(0).getName()); method.addParameter(propDef.type().qualifiedName(), propDef.name()); // method.getJavaDoc().setFullText(javadoc.toString()); /* * } else { javaClass.getMethod(propDef.getName()).setBody(javaClass.getMethod( propDef.getName()).getBody() + body.toString()); } */ } }