Two methods doing the same thing are what I call duplicates… but anyway…
Is checking the return type of a method part of Blueprint spec or not? JP De : Charlie Mordant [mailto:[email protected]] Envoyé : mardi 24 juin 2014 15:51 À : [email protected] Objet : Re: Troubles when creating a builder with blueprint. A Javabean is manipulated by a builder, a Javabean isn't a builder itself. I gave builder pattern implementation and did not duplicated any method of the bean (I made an internal builder class). http://en.wikipedia.org/wiki/Builder_pattern Javabean spec specify setter should be void, blueprint just follows the spec: look at section 7.1 and 8.3 of the JavaBean Spec: http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html Regards, 2014-06-24 15:18 GMT+02:00 CLEMENT Jean-Philippe <[email protected]<mailto:[email protected]>>: I understand I can duplicate methods, either manually or not. My question is rather why some extra code has been added to check return type although it is outside Java spec? ...does Blueprint specify to do so? JP -----Message d'origine----- De : Jean-Baptiste Onofré [mailto:[email protected]<mailto:[email protected]>] Envoyé : mardi 24 juin 2014 14:53 À : [email protected]<mailto:[email protected]> Objet : Re: Troubles when creating a builder with blueprint. Hi JP, you can using a wrapper bean or a factory. Regards JB On 06/24/2014 12:20 PM, CLEMENT Jean-Philippe wrote: > A builder usually returns itself to cumulates changes via Java. It could be > good to use the same method either from Java or Blueprint. From a language > perspective there is nothing which prevents this as a method is identified > via its name and arguments; it is not tied to its return type. > > Is the return type really prohibited from the Blueprint spec or is it left > unspecified? > > JP > > > -----Message d'origine----- > De : Jean-Baptiste Onofré > [mailto:[email protected]<mailto:[email protected]>] Envoyé : lundi 23 > juin 2014 17:49 À : [email protected]<mailto:[email protected]> Objet > : Re: Troubles when > creating a builder with blueprint. > > Hi Christophe, > > in JavaBeans (following by Blueprint), a setter is void, and a getter doesn't > have argument. > So it should be: > > public void setMaxValue(float maxValue) { > this.maxValue=maxValue; > } > public float getMaxValue() { > return this.maxValue; > } > > Regards > JB > > On 06/23/2014 05:34 PM, Lasserre Christophe wrote: >> Hello, >> >> I wrote a builder containing the following setter which does not >> return void (see following sample). >> >> /** >> >> * @param maxValue >> >> * Maximal value for compression law attributes >> >> * @return the builder. >> >> */ >> >> public CompressionLawBuilder setMaxValue(final float maxValue) >> { >> >> this.maxValue = maxValue; >> >> return this; >> >> } >> >> When I try to create the builder via blueprint, the runtime returns me >> the following error message; "Caused by: >> org.osgi.service.blueprint.container.ComponentDefinitionException: No >> setter for maxValue property" >> >> If I change the setter and make it return void, everything works >> perfectly, so is it normal that the return type of the setter has an >> impact on the application behavior ? >> >> Chris. >> >> [@@ OPEN @@] >> > > -- > Jean-Baptiste Onofré > [email protected]<mailto:[email protected]> > http://blog.nanthrax.net > Talend - http://www.talend.com > -- Jean-Baptiste Onofré [email protected]<mailto:[email protected]> http://blog.nanthrax.net Talend - http://www.talend.com -- Charlie Mordant Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent
