SeleniumHQ/selenium — pull request #92 by meza (2013-07-05 15:07:04+00:00)
Title: BrowserType -> enum

BrowserType was a by the book example of using interfaces as types. It is considered as a bad pattern, and should be avoided.

Also, having an ENUM instead of an interface enables proper type checking for browsertypes instead of string equality.

I've not modified anything else in the code right now, but to give a quick example of what it can enable, take the following example from ```HtmlUnitDriver.java```

The code is now:
```java
if (!BrowserType.HTMLUNIT.equals(capabilities.getBrowserName())) {
browserName = capabilities.getBrowserName();
browserVersion = capabilities.getVersion();
}

if (BrowserType.FIREFOX.equals(browserName)) {
return BrowserVersion.FIREFOX_17;
}

if (BrowserType.CHROME.equals(browserName)) {
return BrowserVersion.CHROME;
}

```

With the ENUM, it can be something like:
'''java
if (BrowserType.HTMLUNIT != BrowserType.fromString(capabilities.getBrowserName())) {
browserName = capabilities.getBrowserName();
browserVersion = capabilities.getVersion();
}

BrowserType browserType = BrowserType.fromString(browserName);
switch (browserType) {
case FIREFOX:
return BrowserVersion.FIREFOX_17;
case CHROME:
return BrowserVersion.CHROME;
default:
BrowserVersion.getDefault();
}
'''

This reduces the number of possible errors, because you have less conditional logic, less string comparison and not to mention more readable code.