public DefinedClassOutline(final PluginContext pluginContext, final ClassOutline classOutline) { this.pluginContext = pluginContext; this.classOutline = classOutline; final List<DefinedPropertyOutline> properties = new ArrayList<>(classOutline.getDeclaredFields().length); for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) { properties.add(new DefinedPropertyOutline(fieldOutline)); } this.declaredFields = Collections.unmodifiableList(properties); if (this.classOutline.getSuperClass() != null) { this.superClass = new DefinedClassOutline(this.pluginContext, this.classOutline.getSuperClass()); } else { try { final Class<?> ungeneratedSuperClass = Class.forName(this.classOutline.implClass._extends().fullName()); if (Object.class.equals(ungeneratedSuperClass)) { this.superClass = null; } else { this.superClass = new ReferencedClassOutline(this.pluginContext.codeModel, ungeneratedSuperClass); } } catch (final Exception e) { throw new RuntimeException("Cannot find superclass of " + this.classOutline.target.getName() + ": " + this.classOutline.target.getLocator()); } } }
protected Result createClasses( Outline outline, CClassInfo bean ) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass intf = outline.getClassFactory().createInterface( parent, bean.shortName, bean.getLocator() ); parent = outline.getContainer(bean.parent(), Aspect.IMPLEMENTATION); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName+"Impl", bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); impl._implements(intf); return new Result(intf,impl); }
protected Result createClasses( Outline outline, CClassInfo bean ) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass intf = outline.getClassFactory().createInterface( parent, bean.shortName, bean.getLocator() ); parent = outline.getContainer(bean.parent(), Aspect.IMPLEMENTATION); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName+"Impl", bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); impl._implements(intf); return new Result(intf,impl); }
protected Result createClasses( Outline outline, CClassInfo bean ) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass intf = outline.getClassFactory().createInterface( parent, bean.shortName, bean.getLocator() ); parent = outline.getContainer(bean.parent(), Aspect.IMPLEMENTATION); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName+"Impl", bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); impl._implements(intf); return new Result(intf,impl); }
protected Result createClasses( Outline outline, CClassInfo bean ) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass intf = outline.getClassFactory().createInterface( parent, bean.shortName, bean.getLocator() ); parent = outline.getContainer(bean.parent(), Aspect.IMPLEMENTATION); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName+"Impl", bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); impl._implements(intf); return new Result(intf,impl); }
protected Result createClasses( Outline outline, CClassInfo bean ) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass intf = outline.getClassFactory().createInterface( parent, bean.shortName, bean.getLocator() ); parent = outline.getContainer(bean.parent(), Aspect.IMPLEMENTATION); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName+"Impl", bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); impl._implements(intf); return new Result(intf,impl); }
protected Result createClasses(Outline outline, CClassInfo bean) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName, bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); return new Result(impl,impl); }
protected Result createClasses(Outline outline, CClassInfo bean) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName, bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); return new Result(impl,impl); }
protected Result createClasses(Outline outline, CClassInfo bean) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName, bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); return new Result(impl,impl); }
protected Result createClasses(Outline outline, CClassInfo bean) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName, bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); return new Result(impl,impl); }
private void generateMetaClass(final PluginContext pluginContext, final ClassOutline classOutline, final ErrorHandler errorHandler) throws SAXException { try { final JDefinedClass metaClass = classOutline.implClass._class(JMod.PUBLIC | JMod.STATIC, this.metaClassName); final JMethod visitMethod = generateVisitMethod(classOutline); for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) { if (this.extended) { generateExtendedMetaField(pluginContext, metaClass, visitMethod, fieldOutline); } else { generateNameOnlyMetaField(pluginContext, metaClass, fieldOutline); } } visitMethod.body()._return(JExpr._this()); } catch (final JClassAlreadyExistsException e) { errorHandler.error(new SAXParseException(getMessage("error.metaClassExists", classOutline.implClass.name(), this.metaClassName), classOutline.target.getLocator())); } }
protected Result createClasses(Outline outline, CClassInfo bean) { JClassContainer parent = outline.getContainer( bean.parent(), Aspect.EXPOSED ); JDefinedClass impl = outline.getClassFactory().createClass( parent, JMod.PUBLIC|(parent.isPackage()?0:JMod.STATIC)|(bean.isAbstract()?JMod.ABSTRACT:0), bean.shortName, bean.getLocator() ); impl.annotate2(XmlAccessorTypeWriter.class).value(XmlAccessType.FIELD); return new Result(impl,impl); }
@Override public boolean run(final Outline outline, final Options opt, final ErrorHandler errorHandler) throws SAXException { final PluginContext pluginContext = PluginContext.get(outline, opt, errorHandler); for (final ClassOutline classOutline : outline.getClasses()) { try { final GroupInterfacePlugin groupInterfacePlugin = pluginContext.findPlugin(GroupInterfacePlugin.class); if (groupInterfacePlugin != null) { ModifierGenerator.generateClass(pluginContext, new DefinedClassOutline(pluginContext, classOutline), this.modifierClassName, this.modifierClassName, groupInterfacePlugin.getGroupInterfacesForClass(pluginContext, classOutline.implClass.fullName()), this.modifierMethodName); } else { ModifierGenerator.generateClass(pluginContext, new DefinedClassOutline(pluginContext, classOutline), this.modifierClassName, this.modifierMethodName); } } catch (final JClassAlreadyExistsException e) { errorHandler.error(new SAXParseException(e.getMessage(), classOutline.target.getLocator())); } } return true; }
builderClasses.put(definedClass.fullName(), builderOutline); } catch (final JClassAlreadyExistsException caex) { errorHandler.warning(new SAXParseException(getMessage("error.builderClassExists", definedClass.name()), classOutline.target.getLocator(), caex));
String shortName = base.fullName().substring(base.fullName().indexOf(pkg)+pkg.length()+1); if (cc.target.shortName.equals(shortName)) { getErrorReceiver().error(cc.target.getLocator(), Messages.ERR_KEYNAME_COLLISION.format(shortName));
ClassOutlineImpl existing = valueFactoryNames.put(name,cc); if( existing!=null ) { outline.getErrorReceiver().error(existing.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT.format(name)); outline.getErrorReceiver().error(cc.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT_RELATED.format()); return; CPropertyInfo field = cc.target.getProperty(fieldName); if(field==null) { outline.getErrorReceiver().error(cc.target.getLocator(), Messages.ILLEGAL_CONSTRUCTOR_PARAM.format(fieldName)); continue;
ClassOutlineImpl existing = valueFactoryNames.put(name,cc); if( existing!=null ) { outline.getErrorReceiver().error(existing.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT.format(name)); outline.getErrorReceiver().error(cc.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT_RELATED.format()); return; CPropertyInfo field = cc.target.getProperty(fieldName); if(field==null) { outline.getErrorReceiver().error(cc.target.getLocator(), Messages.ILLEGAL_CONSTRUCTOR_PARAM.format(fieldName)); continue;
ClassOutlineImpl existing = valueFactoryNames.put(name,cc); if( existing!=null ) { outline.getErrorReceiver().error(existing.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT.format(name)); outline.getErrorReceiver().error(cc.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT_RELATED.format()); return; CPropertyInfo field = cc.target.getProperty(fieldName); if(field==null) { outline.getErrorReceiver().error(cc.target.getLocator(), Messages.ILLEGAL_CONSTRUCTOR_PARAM.format(fieldName)); continue;
ClassOutlineImpl existing = valueFactoryNames.put(name,cc); if( existing!=null ) { outline.getErrorReceiver().error(existing.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT.format(name)); outline.getErrorReceiver().error(cc.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT_RELATED.format()); return; CPropertyInfo field = cc.target.getProperty(fieldName); if(field==null) { outline.getErrorReceiver().error(cc.target.getLocator(), Messages.ILLEGAL_CONSTRUCTOR_PARAM.format(fieldName)); continue;
ClassOutlineImpl existing = valueFactoryNames.put(name,cc); if( existing!=null ) { outline.getErrorReceiver().error(existing.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT.format(name)); outline.getErrorReceiver().error(cc.target.getLocator(), Messages.OBJECT_FACTORY_CONFLICT_RELATED.format()); return; CPropertyInfo field = cc.target.getProperty(fieldName); if(field==null) { outline.getErrorReceiver().error(cc.target.getLocator(), Messages.ILLEGAL_CONSTRUCTOR_PARAM.format(fieldName)); continue;