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 { ...@@ -1161,27 +1161,18 @@ public class MainWindow extends Application {
private Pair<Tab,TreeView<Renderable>> getFeatureTabOf(CityObject co) { private Pair<Tab,TreeView<Renderable>> getFeatureTabOf(CityObject co) {
FeatureType coType = co.getFeatureType(); FeatureType coType = co.getFeatureType();
if (coType == FeatureType.BUILDING){ return switch (coType) {
return new Pair<>(buildingsTab, buildingsView); case BUILDING -> new Pair<>(buildingsTab, buildingsView);
} else if (coType == FeatureType.VEGETATION){ case VEGETATION -> new Pair<>(vegetationTab, vegetationView);
return new Pair<>(vegetationTab, vegetationView); case TRANSPORTATION -> new Pair<>(transportationTab, transView);
} else if (coType == FeatureType.TRANSPORTATION){ case TUNNEL -> new Pair<>(tunnelTab, tunnelView);
return new Pair<>(transportationTab,transView); case BRIDGE -> new Pair<>(bridgeTab, bridgeView);
} else if (coType == FeatureType.TUNNEL){ case WATER -> new Pair<>(waterTab, waterView);
return new Pair<>(tunnelTab, tunnelView); case LAND -> new Pair<>(terrainTab, terrainView);
} else if (coType == FeatureType.BRIDGE){ case CITY_FURNITURE -> new Pair<>(cityFurnitureTab, cityFurnitureView);
return new Pair<>(bridgeTab, bridgeView); case GENERIC_CITY_OBJECT -> new Pair<>(otherObjectsTab, otherObjectsView);
} else if (coType == FeatureType.WATER){ default -> throw new IllegalArgumentException("unknown feature type: " + coType);
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);
}
} }
public MainToolBar getMainToolbar() { 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