Re: [Simple-support] Composite attributes
Brought to you by:
niallg
|
From: Sebastian H. <us...@la...> - 2016-02-16 15:15:50
|
Hi, this works technically but creates a lot of verbosity. The intent is to use a composite containing attributes used in a lot of classes. What do you think about a new annotation @AttributeGroup To mark a class containing additional attributes. I have no idea about the effort, but if I provide a patch, would you accept it? -- Best Regards / Viele Grüße Sebastian Hennebrueder ----- http://www.laliluna.de <http://www.laliluna.de/> Software developer and Coach for Java, JEE, Clojure and Java Persistence > Am 16.02.2016 um 15:03 schrieb Niall Gallagher <gal...@ya...>: > > You can write a Converter class, or alternatively you could use an @Resolve to create a object like so > > public class X{ > @Attribute int a; > @Attribute int b; > @Attribute int c; > @Resolve > public Y get() { > return new Y(a,b,c); > } > } > public class Y { > Z z; > int a; > Y(a, b, c){ > this.z = new Z(b,c); > this.a = a; > } > } > public class Z{ > int b; > int c; > Z(a,b){ > } > } > > > From: Sebastian Hennebrueder <us...@la...> > To: sim...@li... > Sent: Tuesday, 16 February 2016, 13:10 > Subject: [Simple-support] Composite attributes > > Hi, > > I have a mapping question for a given XSD. Given a attributeGroup bar, used in many definitions. > > <xs:complexType name=„myElement"> > <xs:complexContent> > <xs:extension base="ns1:someMoreAttributes"> > <xs:attributeGroup ref="ns1:foo" /> > </xs:extension> > </xs:complexContent> > </xs:complexType> > > <xs:attributeGroup name=„foo"> > <xs:attribute name="name" type="xs:string" /> > <xs:attributeGroup ref="ns1:bar" /> > </xs:attributeGroup> > > <xs:attributeGroup name="bar"> > <xs:attribute name=„field1" type="xs:string“/> > <xs:attribute name=„field2" type="xs:string“/> > </xs:attributeGroup> > > xml: > <myElement id="abc“ name="aName“ field1="abc“ field2="def“/> > > I would like to have a class > class MyElement > String id; > String name; > Bar bar; > } > > class Bar{ > String field1; > String field2; > } > > Is there a way to write attributes to a nested class Bar instead of MyElement? > > -- > Best Regards / Viele Grüße > > Sebastian Hennebrueder > > ----- > http://www.laliluna.de <http://www.laliluna.de/> > Software developer and Coach for Java, JEE, Clojure and Java Persistence > > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 <http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140> > _______________________________________________ > Simple-support mailing list > Sim...@li... <mailto:Sim...@li...> > https://lists.sourceforge.net/lists/listinfo/simple-support <https://lists.sourceforge.net/lists/listinfo/simple-support> > > |