Hi Inbar,

In jclouds we usually provide builders that return the result of a "self()"
methos instead of returning "this". This allows proper builder inheritance.
See an api metadata builder examples [1] (and have a look at its superclass
too).

If the builder you are using does not follow that pattern, I think it is
worth changing it. Do you want to try fixing it [2]?

I.

[1]
https://github.com/jclouds/jclouds-chef/blob/master/core/src/main/java/org/jclouds/chef/ChefApiMetadata.java
[2] http://wiki.apache.org/jclouds/How%20to%20Contribute
El 14/01/2014 07:56, "Inbar Stolberg" <[email protected]> escribió:

> Hey guys,
> I have a problem with these too but i believe it is a bit more general.
> CreateImageOptions extends UpdateImageOptions
> and each has a its own public static Builder.
> that means that if i do :
>
>   CreateImageOptions diskFormat = CreateImageOptions.Builder.diskFormat(
>                     <some Format>).size( <some size>);
>
> then this code will not compile since i will get the UpdateImageOptions in
> return from the Builder and i will have to use Casting (face palm) :
>
> CreateImageOptions diskFormat = (CreateImageOptions)
> CreateImageOptions.Builder.diskFormat(
>                     <some Format>).size( <some size>);
>
> may i suggest we use constructors that return "this".
> so this kind of inheritance problems wont happen and we wont have to
> Override every parameter in the parent in order of overcoming this (kinda
> beats the idea of x extends y).
>
> any thoughts/suggestions?
>
> btw this code is in the jclouds openstack lab project...
>
>            Regards Inbar
>

Reply via email to