Given an interface or interfaces, what is the best way to generate an class implementation?
interface Vehicle
{
Engine getEngine();
}
@Generated
class Car implements Vehicle
{
private final Engine engine;
public Car(Engine engine)
{
this.engine = engine;
}
public Engine getEngine()
{
return engine;
}
// generated implementation of equals, hashCode, toString,
}
The class variables should be derived from the getter methods of the interface. Ideally, covariant return types in the interfaces would be handled. The implementation should favour immutability by using private final variables and constructor instantiation. The equals, hashCode and toString methods should be generated.