/*
Copyright 2012 Selenium committers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.openqa.selenium.testing.drivers;

import com.google.common.base.Supplier;

import com.opera.core.systems.OperaDriver;

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

/**
 * @author simonstewart@google.com (Simon Stewart)
 */
public class OperaDriverSupplier implements Supplier<WebDriver> {

  private Capabilities caps;

  public OperaDriverSupplier(Capabilities caps) {
    this.caps = caps;
  }

  public WebDriver get() {
    if (caps == null) {
      return null;
    }

    if (!DesiredCapabilities.opera().getBrowserName().equals(caps.getBrowserName())) {
      return null;
    }

    // It's okay to avoid reflection here because the OperaDriver is a third party dependency
    return new OperaDriver(caps);
  }

}

@@ -30,16 +30,60 @@
 mmitters
+%0ACopyright 2012 Software Freedom Conservancy
 %0A%0ALicens
@@ -875,67 +875,8 @@
 s;%0A%0A
-/**%0A * @author simonstewart@google.com (Simon Stewart)%0A */%0A
 publ
@@ -948,16 +948,22 @@
 private 
+final 
 Capabili
@@ -970,16 +970,24 @@
 ties cap
+abilitie
 s;%0A%0A  pu
@@ -1027,16 +1027,24 @@
 ties cap
+abilitie
 s) %7B%0A   
@@ -1056,15 +1056,31 @@
 .cap
-s = cap
+abilities = capabilitie
 s;%0A 
@@ -1121,16 +1121,24 @@
  if (cap
+abilitie
 s == nul
@@ -1232,16 +1232,24 @@
 uals(cap
+abilitie
 s.getBro
@@ -1413,16 +1413,24 @@
 iver(cap
+abilitie
 s);%0A  %7D%0A
@@ -1431,9 +1431,8 @@
 ;%0A  %7D%0A%0A%7D
-%0A

Make capabilities field final