Commit c07d326d authored by Riegel's avatar Riegel
Browse files

Refactor: Replace if-else with switch

parent e4a745a8
......@@ -1161,27 +1161,18 @@ public class MainWindow extends Application {
private Pair<Tab,TreeView<Renderable>> getFeatureTabOf(CityObject co) {
FeatureType coType = co.getFeatureType();
if (coType == FeatureType.BUILDING){
return new Pair<>(buildingsTab, buildingsView);
} else if (coType == FeatureType.VEGETATION){
return new Pair<>(vegetationTab, vegetationView);
} else if (coType == FeatureType.TRANSPORTATION){
return new Pair<>(transportationTab,transView);
} else if (coType == FeatureType.TUNNEL){
return new Pair<>(tunnelTab, tunnelView);
} else if (coType == FeatureType.BRIDGE){
return new Pair<>(bridgeTab, bridgeView);
} else if (coType == FeatureType.WATER){
return new Pair<>(waterTab, waterView);
} else if (coType == FeatureType.LAND){
return new Pair<>(terrainTab, terrainView);
} else if (coType == FeatureType.CITY_FURNITURE){
return new Pair<>(cityFurnitureTab, cityFurnitureView);
} else if (coType == FeatureType.GENERIC_CITY_OBJECT){
return new Pair<>(otherObjectsTab, otherObjectsView);
} else {
throw new IllegalArgumentException("unknown feature type: " + coType);
}
return switch (coType) {
case BUILDING -> new Pair<>(buildingsTab, buildingsView);
case VEGETATION -> new Pair<>(vegetationTab, vegetationView);
case TRANSPORTATION -> new Pair<>(transportationTab, transView);
case TUNNEL -> new Pair<>(tunnelTab, tunnelView);
case BRIDGE -> new Pair<>(bridgeTab, bridgeView);
case WATER -> new Pair<>(waterTab, waterView);
case LAND -> new Pair<>(terrainTab, terrainView);
case CITY_FURNITURE -> new Pair<>(cityFurnitureTab, cityFurnitureView);
case GENERIC_CITY_OBJECT -> new Pair<>(otherObjectsTab, otherObjectsView);
default -> throw new IllegalArgumentException("unknown feature type: " + coType);
};
}
public MainToolBar getMainToolbar() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment