devonfw / IDEasy

Tool to automate the setup and updates of a development environment for any project (Successor of devonfw-ide).
Apache License 2.0
11 stars 23 forks source link

Small cleanup from PR #724 #750

Closed hohwille closed 5 days ago

hohwille commented 2 weeks ago

From PR #724 see the review comment discussion: https://github.com/devonfw/IDEasy/blob/55db46d0e936fd7e81aaa353b786bc8b825a04e8/cli/src/main/java/com/devonfw/tools/ide/context/GitUrlSyntax.java#L71

I am not sure if the default case can actually occur, because if the enum is set incorrectly, then a IllegalArgumentException is thrown by the Enum class before.

This is a common problem pattern. The best way to solve this in an enum is to avoid the switch at all: simply make the method abstract and create a method implementation for each enum constant. This way, if new enum constants are added, the compiler will force the developer to implement the abstract method and he cannot forget it due to the compiler error. I will create a small cleanup story for this improvement but we can already merge this PR as planned.

This should be cleaned up with this story.