Encapsulating properties in a property/context class
<p>I have created a <code>BicycleProducer</code> interface which has different implementations: <code>OffroadBicycleProducer</code>, <code>FastBicycleProducer</code> and so on. </p>

<p>Each of these factories requires many parameters in order to produce a bicycle. I want to encapsulate these properties in a class and pass it to the <code>produce</code> method. However, the bicycles requires different properties - some may be the same - and I wonder how to do this properly. In the interface of <code>BicycleProducer</code> I have currently a method named <code>produce</code> which takes a parameter <code>BicycleProducingContext</code> which is a interface with all the common properties. And then you have implementations that implement it and add the necassary properties based on what type of bicycle it is. And then you would need to cast it in the <code>produce</code> method....but I don't know. It seem somewhat dodgy (it might not be) I feel.    </p>

<p>Is this is a fine approach or should I do it in another way?</p>

<pre><code>public interface BicycleProducer {
    void produce(BicycleProducingContext context);
}

public class OffroadBicycleProducer implements BicycleProducer {

    public void produce(BicycleProducingContext context) {
        context = (OffroadBicycleProducingContext) context;
    }
}
</code></pre>

<p>and</p>

<pre><code>public interface BicycleProducingContext {

    int numberOfBicycles();
    void brand(String brand);
}

public class OffroadBycycleProducingContext implements BicycleProducingContext {

    //..
}
</code></pre>
