Example usage for com.google.gwt.user.rebind SourceWriter commit

List of usage examples for com.google.gwt.user.rebind SourceWriter commit

Introduction

In this page you can find the example usage for com.google.gwt.user.rebind SourceWriter commit.

Prototype

void commit(TreeLogger logger);

Source Link

Usage

From source file:ch.unifr.pai.twice.comm.serverPush.rebind.RemoteEventDeSerializerGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    // Build a new class, that implements a "paintScreen" method
    JClassType classType;//ww  w  .ja  va 2 s.c  o m

    try {
        classType = context.getTypeOracle().getType(typeName);
        // Here you would retrieve the metadata based on typeName for this
        // Screen
        SourceWriter src = getSourceWriter(classType, context, logger);
        if (src != null) {
            src.println("@Override");
            src.println(
                    "public " + RemoteEvent.class.getName() + "<?> deserialize(" + JSONObject.class.getName()
                            + " o, String t, String string, " + TWICESecurityManager.class.getName()
                            + " securityManager) throws " + MessagingException.class.getName() + " {");
            JClassType abstractRemoteEvent = context.getTypeOracle().findType(RemoteEvent.class.getName());
            src.println("if(t==null){");
            src.println("return null;");
            src.println("}");
            for (JClassType subType : abstractRemoteEvent.getSubtypes()) {
                if (!subType.getPackage().getName()
                        .contains(ch.unifr.pai.twice.comm.serverPush.client.RemoteEventDeserializer.class
                                .getPackage().getName())
                        && !subType.getName().endsWith("Impl")) {
                    src.println("else if(t.equals(" + subType.getQualifiedSourceName() + ".class.getName())){");
                    src.println(subType.getQualifiedSourceName() + " event = " + GWT.class.getName()
                            + ".create(" + subType.getQualifiedSourceName() + ".class);");
                    src.println("return event.deserialize(string, securityManager);");
                    src.println("}");
                }
            }
            src.println("return null;}");
            src.commit(logger);
        }
        return typeName + "Impl";
    } catch (NotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:ch.unifr.pai.twice.comm.serverPush.rebind.RemoteEventSerializerGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    // Build a new class, that implements a "paintScreen" method
    JClassType classType;//from   w  ww  . j  av  a 2  s  .c  o m

    try {
        classType = context.getTypeOracle().getType(typeName);
        JClassType superClass = classType.getSuperclass();
        JClassType[] generics = superClass.isParameterized().getTypeArgs();
        JClassType eventHandlerClass = generics[0];

        // Here you would retrieve the metadata based on typeName for this
        // Screen
        SourceWriter src = getSourceWriter(classType, context, logger);
        if (src != null) {
            src.println("@Override");
            src.println("public " + String.class.getName() + " getEventType(){");
            src.println("return " + classType.getQualifiedSourceName() + ".class.getName();");
            src.println("}");

            if (superClass.getQualifiedSourceName().equals(RemoteEventWrapper.class.getName())
                    || superClass.getQualifiedSourceName().equals(UndoableRemoteEventWrapper.class.getName())) {
                JClassType eventClass = generics[1];
                src.println("@Override");
                src.println("public void wrap(" + eventClass.getQualifiedSourceName() + " event){");
                for (JMethod method : classType.getMethods()) {
                    String realMethodName = method.getName().replaceAll("_", "().");
                    src.println("setProperty(\"" + method.getName() + "\", " + String.class.getName()
                            + ".valueOf(event." + realMethodName + "()));");
                }
                src.println("}");

                for (JMethod method : classType.getMethods()) {
                    if (method.isAbstract()) {
                        src.println();
                        src.println("@Override");
                        src.println("public " + String.class.getName() + " " + method.getName() + "(){");
                        src.println(
                                JSONValue.class.getName() + " value = json.get(\"" + method.getName() + "\");");
                        src.println(
                                "return value!=null && value.isString()!=null ? value.isString().stringValue() : null;");
                        src.println("}");
                    }
                }

                src.println();
            }

            src.println("@Override");
            src.println("public " + GwtEvent.class.getName() + "." + Type.class.getSimpleName() + "<"
                    + eventHandlerClass.getQualifiedSourceName() + "> getAssociatedType() {");
            src.println("\treturn " + classType.getQualifiedSourceName() + ".TYPE;");
            src.println("}");

            src.println();

            src.println("@Override");
            src.println(
                    "protected void dispatch(" + eventHandlerClass.getQualifiedSourceName() + " handler) {");
            // for (JMethod m : eventHandlerClass.getMethods()) {
            // if(!m.getName().equals("undo")){
            boolean undoable = classType
                    .isAssignableTo(context.getTypeOracle().getType(UndoableRemoteEvent.class.getName()));
            if (undoable) {
                src.println("if(isUndo())");
                src.println("handler.undo(this);");
                src.println("else {");
                src.println("handler.saveState(this);");
            }
            src.println("\t handler.onEvent(this);");
            if (undoable) {
                src.println("}");
            }

            // }
            // }
            src.println("}");
            src.println();
            src.println("@Override");
            src.println("public String serialize(" + TWICESecurityManager.class.getName() + " security) throws "
                    + MessagingException.class.getName() + "{");
            for (JField field : classType.getFields()) {
                if (!field.isStatic() && !field.isTransient()) {
                    src.println("if(" + field.getName() + "!=null){");
                    src.println("setProperty(\"" + field.getName() + "\", String.valueOf(" + field.getName()
                            + "));}");

                }
            }
            src.println("return super.serialize(security);");
            src.println("}");
            src.println();
            src.println("@Override");
            src.println(
                    "public " + RemoteEvent.class.getName() + "<" + eventHandlerClass.getQualifiedSourceName()
                            + "> deserialize(String string, " + TWICESecurityManager.class.getName()
                            + " security) throws " + MessagingException.class.getName() + "{");
            src.println(RemoteEvent.class.getName() + " result = super.deserialize(string, security);");
            for (JField field : classType.getFields()) {
                if (!field.isStatic()) {
                    if (String.class.getName().equals(field.getType().getQualifiedSourceName()))
                        src.println(field.getName() + " = getProperty(\"" + field.getName() + "\");");
                    else {
                        src.println("String " + field.getName() + "Tmp = getProperty(\"" + field.getName()
                                + "\");");
                        src.println(field.getName() + " = " + field.getName() + "Tmp!=null ? "
                                + field.getType().getQualifiedSourceName() + ".valueOf(" + field.getName()
                                + "Tmp) : null;");
                    }
                }
            }
            src.println("return result;");
            src.println("}");
            src.commit(logger);

        }
        return typeName + "Impl";

    } catch (NotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:ch.unifr.pai.twice.module.rebind.TWICEModuleGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    // Build a new class, that implements a "paintScreen" method
    JClassType classType;/*from w  w w . j  ava2s .c o  m*/
    try {
        classType = context.getTypeOracle().getType(typeName);
        JClassType genericClass = getGenericClass(classType);

        SourceWriter src = getSourceWriter(classType, context, logger);
        if (src != null) {
            src.println("@Override");
            src.println("public " + Map.class.getName() + "<" + String.class.getName() + ", "
                    + Object.class.getName() + "> getConfigurableFields("
                    + genericClass.getQualifiedSourceName() + " instance){");
            src.println(Map.class.getName() + "<" + String.class.getName() + ", " + Object.class.getName()
                    + "> result = new " + HashMap.class.getName() + "<" + String.class.getName() + ", "
                    + Object.class.getName() + ">();");
            for (JField f : genericClass.getFields()) {
                Configurable c = f.getAnnotation(Configurable.class);
                if (c != null && !f.isFinal() && !f.isPrivate() && !f.isProtected()) {
                    src.println("result.put(\"" + c.value() + "\", instance." + f.getName() + ");");
                }
            }
            src.println("return result;");
            src.println("}");

            src.println("@Override");
            src.println("public void configure(" + Map.class.getName() + "<" + String.class.getName() + ", "
                    + String.class.getName() + "> properties, " + genericClass.getQualifiedSourceName()
                    + " instance){");
            src.println("for(" + String.class.getName() + " key : properties.keySet()){");
            src.println("String value = properties.get(key);");
            src.println("if(key==null){");
            src.println("}");
            for (JField f : genericClass.getFields()) {
                Configurable c = f.getAnnotation(Configurable.class);
                if (c != null && !f.isFinal() && !f.isPrivate() && !f.isProtected()) {
                    JPrimitiveType t = f.getType().isPrimitive();
                    if (t != null) {
                        src.println("else if(key.equals(\"" + c.value() + "\")){");
                        switch (t) {
                        case INT:
                            src.println("instance." + f.getName() + "=" + Integer.class.getName()
                                    + ".parseInt(value);");
                            break;
                        case BOOLEAN:
                            src.println("instance." + f.getName() + "=" + Boolean.class.getName()
                                    + ".parseBoolean(value);");
                            break;
                        case DOUBLE:
                            src.println("instance." + f.getName() + "=" + Double.class.getName()
                                    + ".parseDouble(value);");
                            break;
                        case FLOAT:
                            src.println("instance." + f.getName() + "=" + Float.class.getName()
                                    + ".parseFloat(value);");
                            break;
                        case LONG:
                            src.println("instance." + f.getName() + "=" + Long.class.getName()
                                    + ".parseLong(value);");
                            break;
                        default:
                            throw new RuntimeException("The primitive type \"" + t.name()
                                    + "\" is not supported for configuration");
                        }
                    } else if (f.getType().getQualifiedSourceName().equals(String.class.getName())) {
                        src.println("instance." + f.getName() + "=value");
                    } else {
                        throw new RuntimeException("The type \"" + f.getType().getQualifiedSourceName()
                                + "\" is not supported for configuration");
                    }
                    src.println("}");
                }
            }
            src.println("}");
            src.println("}");

            src.println("@Override");
            src.println("public " + RunAsyncCallback.class.getName() + " instantiate(final "
                    + AsyncCallback.class.getName() + "<" + genericClass.getQualifiedSourceName()
                    + "> callback){");
            src.println("return new " + RunAsyncCallback.class.getName() + "(){");
            src.println("@Override");
            src.println("public void onSuccess(){");
            src.println(genericClass.getQualifiedSourceName() + " module = " + GWT.class.getName() + ".create("
                    + genericClass.getQualifiedSourceName() + ".class);");
            src.println("//start(module);");
            src.println("callback.onSuccess(module);");
            src.println("}");
            src.println("@Override");
            src.println("public void onFailure(" + Throwable.class.getName() + " reason){");
            src.println("callback.onFailure(reason);");
            src.println("}");
            src.println("};");
            src.println("}");
            src.commit(logger);
        }

        return typeName + "Impl";

    } catch (NotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.ait.ext4j.rebind.BeanModelGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    oracle = context.getTypeOracle();/*from  w w w .ja va  2  s.  c  o  m*/
    beanModelMarkerType = oracle.findType(BeanModelMarker.class.getName());
    beanModelTagType = oracle.findType(BeanModelTag.class.getName());

    try {
        // final all beans and bean markers
        beans = new ArrayList<JClassType>();
        JClassType[] types = oracle.getTypes();
        for (JClassType type : types) {
            if (isBeanMarker(type)) {
                beans.add(getMarkerBean(type));
            } else if (isBean(type)) {
                beans.add(type);
            }
        }

        final String genPackageName = BeanModelLookup.class.getPackage().getName();
        final String genClassName = "BeanModelLookupImpl";

        ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(genPackageName,
                genClassName);
        composer.setSuperclass(BeanModelLookup.class.getCanonicalName());
        composer.addImport(BeanModelFactory.class.getName());
        composer.addImport(Map.class.getName());
        composer.addImport(FastMap.class.getName());

        PrintWriter pw = context.tryCreate(logger, genPackageName, genClassName);

        if (pw != null) {
            SourceWriter sw = composer.createSourceWriter(context, pw);

            sw.println("private Map<String, BeanModelFactory> m;");

            sw.println("public BeanModelFactory getFactory(Class b) {");
            sw.indent();
            sw.println("String n = b.getName();");
            sw.println("if (m == null) {");
            sw.indentln("m = new FastMap<BeanModelFactory>();");
            sw.println("}");
            sw.println("if (m.get(n) == null) {");
            sw.indent();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < beans.size(); i++) {
                JClassType bean = beans.get(i);
                String name = createBean(bean, logger, context);
                String factory = createFactory(bean, name, logger, context);

                if (i > 0) {
                    sw.print(" else ");
                }
                sw.println("if (" + bean.getQualifiedSourceName() + ".class.getName().equals(n)) {");
                sw.indentln("m" + i + "();");

                sb.append("private void m" + i + "() {\n");
                sb.append("  m.put(" + bean.getQualifiedSourceName() + ".class.getName(), new " + factory
                        + "());\n");
                sb.append("}\n");

                sw.print("}");
            }
            sw.outdent();
            sw.println("}");
            sw.println("return m.get(n);");
            sw.outdent();
            sw.println("}");

            sw.println(sb.toString());
            sw.commit(logger);
        }

        return composer.getCreatedClassName();

    } catch (Exception e) {
        logger.log(TreeLogger.ERROR, "Class " + typeName + " not found.", e);
        throw new UnableToCompleteException();
    }

}

From source file:com.ait.ext4j.rebind.BeanModelGenerator.java

License:Apache License

protected String createFactory(JClassType bean, String beanModelName, TreeLogger logger,
        GeneratorContext context) throws Exception {
    final String genPackageName = BeanModelLookup.class.getPackage().getName();
    final String genClassName = "BeanModel_" + bean.getQualifiedSourceName().replace(".", "_") + "_Factory";

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(genPackageName, genClassName);
    composer.setSuperclass(BeanModelFactory.class.getCanonicalName());
    PrintWriter pw = context.tryCreate(logger, genPackageName, genClassName);

    if (pw != null) {
        List<JMethod> getters = findGetters(bean);
        String typeName = bean.getQualifiedSourceName();
        SourceWriter sw = composer.createSourceWriter(context, pw);
        sw.println("public BeanModel newInstance() {");
        sw.println("return new " + beanModelName + "();");
        sw.println("}");

        sw.println("public BeanModel createModel(Object bean) {");
        sw.println("BeanModel model = newInstance();");
        for (JMethod method : getters) {
            String s = method.getName();
            String p = lowerFirst(s.substring(s.startsWith("g") ? 3 : 2)); // get
            sw.println("model.set(\"" + p + "\"," + " ((" + typeName + ")bean)." + s + "()" + ");");
        }/* w  w  w.  ja  va2  s .c  o  m*/
        sw.println("model.setBean(bean);");
        sw.println("return model;");
        sw.println("}");
        sw.commit(logger);
    }
    return composer.getCreatedClassName();
}

From source file:com.ait.ext4j.rebind.BeanModelGenerator.java

License:Apache License

protected String createBean(JClassType bean, TreeLogger logger, GeneratorContext context) throws Exception {
    final String genPackageName = bean.getPackage().getName();
    final String genClassName = "BeanModel_" + bean.getQualifiedSourceName().replace(".", "_");

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(genPackageName, genClassName);
    composer.setSuperclass(BeanModel.class.getCanonicalName());
    composer.addImport(BeanModel.class.getName());
    composer.addImport(NestedModelUtil.class.getName());
    PrintWriter pw = context.tryCreate(logger, genPackageName, genClassName);

    if (pw != null) {
        List<JMethod> getters = findGetters(bean);
        List<JMethod> setters = findSetters(bean);
        SourceWriter sw = composer.createSourceWriter(context, pw);

        sw.println("public " + genClassName + "(){");
        for (JMethod method : getters) {
            String s = method.getName();
            String p = lowerFirst(s.substring(s.startsWith("g") ? 3 : 2)); // get
                                                                           // or
                                                                           // is
            sw.println("beanProperties.add(\"" + p + "\");");
        }//  www .ja  va 2 s .co  m
        sw.println("}");

        createGetMethods(getters, sw, bean.getQualifiedSourceName());
        createSetMethods(setters, sw, bean.getQualifiedSourceName());

        // delegate equals to bean
        sw.println("public boolean equals(Object obj) {");
        sw.println("  if (obj instanceof " + "BeanModel" + ") {");
        sw.println("    obj = ((BeanModel)obj).getBean();");
        sw.println("  }");
        sw.println("  return bean.equals(obj);");
        sw.println("}");

        // delegate hashCode to bean
        sw.println("public int hashCode(){");
        sw.println("  return bean.hashCode();");
        sw.println("}");

        sw.commit(logger);
    }
    return composer.getCreatedClassName();
}

From source file:com.ait.ext4j.rebind.TemplateGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    TypeOracle oracle = context.getTypeOracle();
    this.templatesInterface = oracle.findType(Name.getSourceNameForClass(Template.class));

    JClassType interfaceType;/*w  w w  .j  a v a 2  s .  c o m*/
    try {
        interfaceType = oracle.getType(typeName);
    } catch (NotFoundException e) {
        throw new RuntimeException(e);
    }

    if (interfaceType.isInterface() == null) {
        logger.log(TreeLogger.ERROR, typeName + " is not an interface type");
        throw new UnableToCompleteException();
    }
    if (!interfaceType.isAssignableTo(templatesInterface)) {
        logger.log(Type.ERROR, "This isn't a Template subtype...");
        throw new UnableToCompleteException();
    }

    String content = getTemplateContent(context, logger, interfaceType);
    String packageName = interfaceType.getPackage().getName();
    String className = "Template_For_" + interfaceType.getQualifiedSourceName().replace(".", "_");

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, className);
    composer.addImport(SafeHtml.class.getName());
    composer.addImport(SafeHtmlUtils.class.getName());
    composer.addImplementedInterface(Template.class.getName());

    PrintWriter pw = context.tryCreate(logger, packageName, className);
    SourceWriter sw = composer.createSourceWriter(context, pw);

    sw.println("  public SafeHtml getContent(){");
    sw.println("      return SafeHtmlUtils.fromSafeConstant(\"" + content + "\");");
    sw.println("  }");
    sw.println("");
    sw.println("");
    sw.println("  public SafeHtml getSafeContent(){");
    sw.println("      return SafeHtmlUtils.fromString(\"" + content + "\");");
    sw.println("  }");

    sw.commit(logger);
    return composer.getCreatedClassName();

}

From source file:com.ait.toolkit.rebind.BeanModelGenerator.java

License:Open Source License

@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
        throws UnableToCompleteException {
    oracle = context.getTypeOracle();/*  w w  w. jav  a2s  .c  o m*/
    beanModelMarkerType = oracle.findType(BeanMarker.class.getName());
    beanModelTagType = oracle.findType(BeanTag.class.getName());

    try {
        // final all beans and bean markers
        beans = new ArrayList<JClassType>();
        JClassType[] types = oracle.getTypes();
        for (JClassType type : types) {
            if (isBeanMarker(type)) {
                beans.add(getMarkerBean(type));
            } else if (isBean(type)) {
                beans.add(type);
            }
        }

        final String genPackageName = BeanLookup.class.getPackage().getName();
        final String genClassName = "BeanLookupImpl";

        ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(genPackageName,
                genClassName);
        composer.setSuperclass(BeanLookup.class.getCanonicalName());
        composer.addImport(BeanFactory.class.getName());
        composer.addImport(Map.class.getName());
        composer.addImport(FastMap.class.getName());

        PrintWriter pw = context.tryCreate(logger, genPackageName, genClassName);

        if (pw != null) {
            SourceWriter sw = composer.createSourceWriter(context, pw);

            sw.println("private Map<String, BeanFactory> m;");

            sw.println("public BeanFactory getFactory(Class b) {");
            sw.indent();
            sw.println("String n = b.getName();");
            sw.println("if (m == null) {");
            sw.indentln("m = new FastMap<BeanFactory>();");
            sw.println("}");
            sw.println("if (m.get(n) == null) {");
            sw.indent();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < beans.size(); i++) {
                JClassType bean = beans.get(i);
                String name = createBean(bean, logger, context);
                String factory = createFactory(bean, name, logger, context);

                if (i > 0) {
                    sw.print(" else ");
                }
                sw.println("if (" + bean.getQualifiedSourceName() + ".class.getName().equals(n)) {");
                sw.indentln("m" + i + "();");

                sb.append("private void m" + i + "() {\n");
                sb.append("  m.put(" + bean.getQualifiedSourceName() + ".class.getName(), new " + factory
                        + "());\n");
                sb.append("}\n");

                sw.print("}");
            }
            sw.outdent();
            sw.println("}");
            sw.println("return m.get(n);");
            sw.outdent();
            sw.println("}");

            sw.println(sb.toString());
            sw.commit(logger);
        }

        return composer.getCreatedClassName();

    } catch (Exception e) {
        logger.log(TreeLogger.ERROR, "Class " + typeName + " not found.", e);
        throw new UnableToCompleteException();
    }

}

From source file:com.ait.toolkit.rebind.BeanModelGenerator.java

License:Open Source License

protected String createFactory(JClassType bean, String beanModelName, TreeLogger logger,
        GeneratorContext context) throws Exception {
    final String genPackageName = BeanLookup.class.getPackage().getName();
    final String genClassName = "Bean_" + bean.getQualifiedSourceName().replace(".", "_") + "_Factory";

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(genPackageName, genClassName);
    composer.setSuperclass(BeanFactory.class.getCanonicalName());
    PrintWriter pw = context.tryCreate(logger, genPackageName, genClassName);

    if (pw != null) {
        List<JMethod> getters = findGetters(bean);
        String typeName = bean.getQualifiedSourceName();
        SourceWriter sw = composer.createSourceWriter(context, pw);
        sw.println("public Bean newInstance() {");
        sw.println("return new " + beanModelName + "();");
        sw.println("}");

        sw.println("public Bean createModel(Object bean) {");
        sw.println("Bean model = newInstance();");
        for (JMethod method : getters) {
            String s = method.getName();
            String p = lowerFirst(s.substring(s.startsWith("g") ? 3 : 2)); // get
            sw.println("model.set(\"" + p + "\"," + " ((" + typeName + ")bean)." + s + "()" + ");");
        }//from   w  ww.ja v a2  s  . com
        sw.println("model.setBean(bean);");
        sw.println("return model;");
        sw.println("}");
        sw.commit(logger);
    }
    return composer.getCreatedClassName();
}

From source file:com.ait.toolkit.rebind.BeanModelGenerator.java

License:Open Source License

protected String createBean(JClassType bean, TreeLogger logger, GeneratorContext context) throws Exception {
    final String genPackageName = bean.getPackage().getName();
    final String genClassName = "Bean_" + bean.getQualifiedSourceName().replace(".", "_");

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(genPackageName, genClassName);
    composer.setSuperclass(Bean.class.getCanonicalName());
    composer.addImport(Bean.class.getName());
    composer.addImport(NestedModelUtil.class.getName());
    PrintWriter pw = context.tryCreate(logger, genPackageName, genClassName);

    if (pw != null) {
        List<JMethod> getters = findGetters(bean);
        List<JMethod> setters = findSetters(bean);
        SourceWriter sw = composer.createSourceWriter(context, pw);

        sw.println("public " + genClassName + "(){");
        for (JMethod method : getters) {
            String s = method.getName();
            String p = lowerFirst(s.substring(s.startsWith("g") ? 3 : 2)); // get
            // or
            // is
            sw.println("beanProperties.add(\"" + p + "\");");
        }/*w  ww . ja  v  a  2  s . c  om*/
        sw.println("}");

        createGetMethods(getters, sw, bean.getQualifiedSourceName());
        createSetMethods(setters, sw, bean.getQualifiedSourceName());

        // delegate equals to bean
        sw.println("public boolean equals(Object obj) {");
        sw.println("  if (obj instanceof " + "Bean" + ") {");
        sw.println("    obj = ((Bean)obj).getBean();");
        sw.println("  }");
        sw.println("  return bean.equals(obj);");
        sw.println("}");

        // delegate hashCode to bean
        sw.println("public int hashCode(){");
        sw.println("  return bean.hashCode();");
        sw.println("}");

        sw.commit(logger);
    }
    return composer.getCreatedClassName();
}