Like some answers above state, you could use an abstract method to implement them on the Enums. Unlike many say, you CAN use reflection to instantiate an Object with parameters, like this:
public enum BuildingType {
FARM(Farm.class), SHOP(Shop.class), HOUSE(House.class);
private final Class<? extends Building> buildingType;
private BuildingType(Class<? extends Building> buildingType ) {
this.buildingType = buildingType;
}
public Building getBuilding( Furniture... furniture ) {
Building building = null;
try {
Constructor<? extends Building> constructor =
( Constructor<? extends Building> ) buildingType.getDeclaredConstructor( Furniture[].class );
building = constructor.newInstance( furniture );
}
catch ( NoSuchMethodException | SecurityException |
InstantiationException | IllegalAccessException |
IllegalArgumentException | InvocationTargetException ex ) {
//I have a method to handle exceptions, you could do the same,
//but in principle it shouldn't be necessary.
//handleExceptionsGracefully(...);
}
return building;
}
}
For more on reflection, I advise you to read this from O'reilly: http://chimera.labs.oreilly.com/books/1234000001805/ch07.html#learnjava3-CHP-7-SECT-2
And to Bohemian: for convention, Java Enums should be Upercase, and if you don't have arguments in Enums, you can remove the parentheses.
I hope I have helped.
Have a nice day. :)