Re: [Simple-support] Composite attributes
Brought to you by:
niallg
|
From: Sebastian H. <us...@la...> - 2016-02-16 20:45:51
|
Hi, I checked the use of a converter. I wonder if it is the right solution here. Imagine a pair of attributes: from and to Those are expressed as attributeGroup and used in many elements. I would need to provide a converter for every element. I had a look at the code base. I like the code quality and structure a lot but it is quite a lot of code. I struggled to add a new Label which creates new instances, parses nested fields and add the attribute to the attribute map. I give up here. I don’t thing I can provide a quality patch. The idea I wanted to achieve was: Composition for attributes. Given multiple attributes used in various places in an XML, for example a time range (from, to). In XSD this can be expressed as an attributeGroup. Many elements can contain this attributeGroup. I would like this attributes to be added to a Composite class containing the attributes instead of mapping it to fields in the class. Wherever you use those attributes, you add an annotation and @AttributeGroup Range range; -- 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 16:15 schrieb Sebastian Hennebrueder <us...@la...>: > > 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... <mailto: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... <mailto:us...@la...>> >> To: sim...@li... <mailto: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> >> >> > > ------------------------------------------------------------------------------ > 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_______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |