package me.alb_i986.selenium.tinafw.domain;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public enum SupportedBrowser {

	CHROME("chrome", "ChromeDriver", DesiredCapabilities.chrome()),
	FIREFOX("firefox", "FirefoxDriver", DesiredCapabilities.firefox()),
	SAFARI("safari", "SafariDriver", DesiredCapabilities.safari()),
	IE("ie", "InternetExplorerDriver", DesiredCapabilities.internetExplorer()),
	HTML_UNIT("htmlunit", "HtmlUnitDriver", DesiredCapabilities.htmlUnit()),
	;

	private static final String SELENIUM_PACKAGE = "org.openqa.selenium";
	
	private String fullyQualifiedClassName;
	private DesiredCapabilities capabilities;

	private SupportedBrowser(String subPackage, String className, DesiredCapabilities capabilities) {
		this.fullyQualifiedClassName = SELENIUM_PACKAGE + "." + subPackage + "." + className;
		this.capabilities = capabilities;
	}
	
	public String toFullyQualifiedClassName() {
		return fullyQualifiedClassName;
	}

	public DesiredCapabilities toCapabilities() {
		return this.capabilities;
	}

	/**
	 * @return the concrete WebDriver class corresponding to this enum
	 * @throws ClassNotFoundException
	 */
	@SuppressWarnings("unchecked")
	public Class<WebDriver> toClass() throws ClassNotFoundException {
		return (Class<WebDriver>) Class.forName(toFullyQualifiedClassName());
	}
	
	/**
	 * @return the lower cased name of the enum constant
	 */
	@Override
	public String toString() {
		return super.toString().toLowerCase();
	}
}
@@ -107,34 +107,286 @@
 ium.
-remote.DesiredCapabilities
+chrome.ChromeDriver;%0Aimport org.openqa.selenium.firefox.FirefoxDriver;%0Aimport org.openqa.selenium.htmlunit.HtmlUnitDriver;%0Aimport org.openqa.selenium.ie.InternetExplorerDriver;%0Aimport org.openqa.selenium.remote.DesiredCapabilities;%0Aimport org.openqa.selenium.safari.SafariDriver
 ;%0A%0Ap
@@ -428,19 +428,8 @@
 OME(
-%22chrome%22, %22
 Chro
@@ -432,25 +432,30 @@
 ChromeDriver
-%22
+.class
 , DesiredCap
@@ -488,20 +488,8 @@
 FOX(
-%22firefox%22, %22
 Fire
@@ -493,25 +493,30 @@
 irefoxDriver
-%22
+.class
 , DesiredCap
@@ -549,19 +549,8 @@
 ARI(
-%22safari%22, %22
 Safa
@@ -553,25 +553,30 @@
 SafariDriver
-%22
+.class
 , DesiredCap
@@ -604,15 +604,8 @@
 %09IE(
-%22ie%22, %22
 Inte
@@ -618,25 +618,30 @@
 plorerDriver
-%22
+.class
 , DesiredCap
@@ -686,21 +686,8 @@
 NIT(
-%22htmlunit%22, %22
 Html
@@ -696,17 +696,22 @@
 itDriver
-%22
+.class
 , Desire
@@ -754,111 +754,40 @@
 ate 
-static final String SELENIUM_PACKAGE = %22org.openqa.selenium%22;%0A%09%0A%09private String fullyQualifiedClassName
+DesiredCapabilities capabilities
 ;%0A%09p
@@ -797,427 +797,256 @@
 ate 
-DesiredCapabilities capabilities;%0A%0A%09private SupportedBrowser(String subPackage, String className, DesiredCapabilities capabilities) %7B%0A%09%09this.fullyQualifiedClassName = SELENIUM_PACKAGE + %22.%22 + subPackage + %22.%22 + className;%0A%09%09this.capabilities = capabilities;%0A%09%7D%0A%09%0A%09public String toFullyQualifiedClassName() %7B%0A%09%09return fullyQualifiedClassName;%0A%09%7D%0A%0A%09public DesiredCapabilities toCapabilities() %7B%0A%09%09return this.capabilities
+Class%3C?%3E clazz;%0A%0A%09private SupportedBrowser(Class%3C?%3E clazz, DesiredCapabilities capabilities) %7B%0A%09%09this.clazz = clazz;%0A%09%09this.capabilities = capabilities;%0A%09%7D%0A%09%0A%09/**%0A%09 * @see Class#getName()%0A%09 */%0A%09public String toClassName() %7B%0A%09%09return clazz.getName()
 ;%0A%09%7D
@@ -1307,40 +1307,104 @@
 e(to
-FullyQualifiedClassName())
+ClassName());%0A%09%7D%0A%0A%09public DesiredCapabilities toCapabilities() %7B%0A%09%09return this.capabilities
 ;%0A%09%7D%0A
-%09
 %0A%09/*

clean up SupportedBrowser#toClassName: leverage Class