I have the following classes:
class Walls { }
class Furniture { }
class Layout<T extends Walls | Furniture> { }
class Space extends Layout<Walls> { }
class Room extends Layout<Furniture> { }
I need to create these two classes:
class SpaceController extends LayoutController<Space> { }
class RoomController extends LayoutController<Room> {}
To do this, I can't create LayoutController class like this:
class LayoutController<T extends Layout>{ }
because Layout needs a Type parameter.
I can instead create this:
class LayoutController<U, T extends Layout<U extends Walls | Furniture>>{ }
but that would mean I will have to do this:
class SpaceController extends LayoutController<Walls, Space> { }
class RoomController extends LayoutController<Furniture, Room> {}
which I feel is redundant. Moreover, it opens up room for errors. There's nothing stopping me from writing:
class RoomController extends LayoutController<Walls, Room> {}
How do I solve this?
More details about LayoutController:
class LayoutController<T> extends React.Component<{}, LayoutControllerState<T>>() { }
interface LayoutControllerState<T> {
selectedLayout: T;
}
LayoutController? It seems that it could be defined asclass LayoutController<T extends Walls | Furniture>but maybe I'm missing something.Layout<T>whereTis generic parameter ofLayoutControllerclass SpaceController extends LayoutController<Walls> { }, notLayoutController<Space>