Skip to content

Commit

Permalink
Remove redundant generics type (#2141)
Browse files Browse the repository at this point in the history
  • Loading branch information
asashour authored and lukeis committed May 21, 2016
1 parent 1c33929 commit cc6b935
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int getNumberOfActions() {
}

public List<Action> asList() {
ImmutableList.Builder<Action> builder = new ImmutableList.Builder<Action>();
ImmutableList.Builder<Action> builder = new ImmutableList.Builder<>();
for (Action action : actionsList) {
if (action instanceof MultiAction) {
builder.addAll(((MultiAction) action).getActions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class TemporaryFilesystem {

private final Set<File> temporaryFiles = new CopyOnWriteArraySet<File>();
private final Set<File> temporaryFiles = new CopyOnWriteArraySet<>();
private final File baseDir;
private final Thread shutdownHook = new Thread() { // Thread safety reviewed
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ExecutableFinder {
private static final Method JDK6_CAN_EXECUTE = findJdk6CanExecuteMethod();

private final ImmutableSet.Builder<String> pathSegmentBuilder =
new ImmutableSet.Builder<String>();
new ImmutableSet.Builder<>();

/**
* Find the executable by scanning the file system and the PATH. In the case of Windows this
Expand Down
2 changes: 1 addition & 1 deletion java/client/src/org/openqa/selenium/remote/RemoteLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Set<String> getAvailableLogTypes() {
Object raw = executeMethod.execute(DriverCommand.GET_AVAILABLE_LOG_TYPES, null);
@SuppressWarnings("unchecked")
List<String> rawList = (List<String>) raw;
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<String>();
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
for (String logType : rawList) {
builder.add(logType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void init(Capabilities desiredCapabilities, Capabilities requiredCapabil
keyboard = new RemoteKeyboard(executeMethod);
mouse = new RemoteMouse(executeMethod);

ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<String>();
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();

boolean isProfilingEnabled = desiredCapabilities != null &&
desiredCapabilities.is(CapabilityType.ENABLE_PROFILING_CAPABILITY);
Expand Down Expand Up @@ -237,7 +237,7 @@ protected void startSession(Capabilities desiredCapabilities) {
protected void startSession(Capabilities desiredCapabilities,
Capabilities requiredCapabilities) {
ImmutableMap.Builder<String, Capabilities> paramBuilder =
new ImmutableMap.Builder<String, Capabilities>();
new ImmutableMap.Builder<>();
paramBuilder.put("desiredCapabilities", desiredCapabilities);
if (requiredCapabilities != null) {
paramBuilder.put("requiredCapabilities", requiredCapabilities);
Expand Down Expand Up @@ -546,7 +546,7 @@ public Set<String> getWindowHandles() {
Object value = response.getValue();
try {
List<String> returnedValues = (List<String>) value;
return new LinkedHashSet<String>(returnedValues);
return new LinkedHashSet<>(returnedValues);
} catch (ClassCastException ex) {
throw new WebDriverException(
"Returned value cannot be converted to List<String>: " + value, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SafariDriverServer {
private final int port;

private final BlockingQueue<WebSocketConnection> connections =
new SynchronousQueue<WebSocketConnection>();
new SynchronousQueue<>();

private ServerBootstrap bootstrap;
private Channel serverChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class WebSocketConnection {
private final Channel channel;

private final AtomicReference<SettableFuture<String>> pendingResponse =
new AtomicReference<SettableFuture<String>>();
new AtomicReference<>();

public WebSocketConnection(Channel channel) {
this.channel = channel;
Expand Down
12 changes: 6 additions & 6 deletions java/client/test/org/openqa/selenium/remote/RemoteLogsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void createMocksAndRemoteLogs() {

@Test
public void canGetProfilerLogs() {
List<LogEntry> entries = new ArrayList<LogEntry>();
List<LogEntry> entries = new ArrayList<>();
entries.add(new LogEntry(Level.INFO, 0, "hello"));
when(localLogs.get(LogType.PROFILER)).thenReturn(new LogEntries(entries));

Expand All @@ -79,7 +79,7 @@ public void canGetProfilerLogs() {

@Test
public void canGetLocalProfilerLogsIfNoRemoteProfilerLogSupport() {
List<LogEntry> entries = new ArrayList<LogEntry>();
List<LogEntry> entries = new ArrayList<>();
entries.add(new LogEntry(Level.INFO, 0, "hello"));
when(localLogs.get(LogType.PROFILER)).thenReturn(new LogEntries(entries));

Expand All @@ -97,7 +97,7 @@ public void canGetLocalProfilerLogsIfNoRemoteProfilerLogSupport() {

@Test
public void canGetClientLogs() {
List<LogEntry> entries = new ArrayList<LogEntry>();
List<LogEntry> entries = new ArrayList<>();
entries.add(new LogEntry(Level.SEVERE, 0, "hello"));
when(localLogs.get(LogType.CLIENT)).thenReturn(new LogEntries(entries));

Expand Down Expand Up @@ -127,20 +127,20 @@ public void canGetServerLogs() {

@Test
public void canGetAvailableLogTypes() {
List<String> remoteAvailableLogTypes = new ArrayList<String>();
List<String> remoteAvailableLogTypes = new ArrayList<>();
remoteAvailableLogTypes.add(LogType.PROFILER);
remoteAvailableLogTypes.add(LogType.SERVER);

when(executeMethod.execute(DriverCommand.GET_AVAILABLE_LOG_TYPES, null))
.thenReturn(remoteAvailableLogTypes);

Set<String> localAvailableLogTypes = new HashSet<String>();
Set<String> localAvailableLogTypes = new HashSet<>();
localAvailableLogTypes.add(LogType.PROFILER);
localAvailableLogTypes.add(LogType.CLIENT);

when(localLogs.getAvailableLogTypes()).thenReturn(localAvailableLogTypes);

Set<String> expected = new HashSet<String>();
Set<String> expected = new HashSet<>();
expected.add(LogType.CLIENT);
expected.add(LogType.PROFILER);
expected.add(LogType.SERVER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class ExpectedConditionsTest {
public void setUpMocks() {
MockitoAnnotations.initMocks(this);

wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(1, TimeUnit.SECONDS)
.pollingEvery(250, TimeUnit.MILLISECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void shouldWaitUntilReturnValueOfConditionIsNotNull() throws InterruptedE
when(mockClock.isNowBefore(2L)).thenReturn(true);
when(mockCondition.apply(mockDriver)).thenReturn(null, ARBITRARY_VALUE);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class, NoSuchFrameException.class);
Expand All @@ -82,7 +82,7 @@ public void shouldWaitUntilABooleanResultIsTrue() throws InterruptedException {
when(mockClock.isNowBefore(2L)).thenReturn(true);
when(mockCondition.apply(mockDriver)).thenReturn(false, false, true);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class, NoSuchFrameException.class);
Expand All @@ -98,7 +98,7 @@ public void checksTimeoutAfterConditionSoZeroTimeoutWaitsCanSucceed() {
when(mockClock.isNowBefore(2L)).thenReturn(false);
when(mockCondition.apply(mockDriver)).thenReturn(null);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS);
try {
wait.until(mockCondition);
Expand All @@ -117,7 +117,7 @@ public void canIgnoreMultipleExceptions() throws InterruptedException {
.thenThrow(new NoSuchFrameException(""))
.thenReturn(ARBITRARY_VALUE);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class, NoSuchFrameException.class);
Expand All @@ -134,7 +134,7 @@ public void propagatesUnIgnoredExceptions() {
when(mockClock.laterBy(0L)).thenReturn(2L);
when(mockCondition.apply(mockDriver)).thenThrow(exception);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class, NoSuchFrameException.class);
Expand All @@ -157,7 +157,7 @@ public void timeoutMessageIncludesLastIgnoredException() {
.thenReturn(null);
when(mockClock.isNowBefore(2L)).thenReturn(false);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchWindowException.class);
Expand All @@ -179,7 +179,7 @@ public void timeoutMessageIncludesCustomMessage() {
when(mockCondition.apply(mockDriver)).thenReturn(null);
when(mockClock.isNowBefore(2L)).thenReturn(false);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.withMessage("Expected custom timeout message");

Expand All @@ -203,7 +203,7 @@ public void timeoutMessageIncludesCustomMessageEvaluatedOnFailure() {
when(mockCondition.apply(mockDriver)).thenReturn(null);
when(mockClock.isNowBefore(2L)).thenReturn(false);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.withMessage(new Supplier<String>() {
@Override
Expand Down Expand Up @@ -258,7 +258,7 @@ public void canIgnoreThrowables() {
when(mockCondition.apply(mockDriver)).thenThrow(exception);
when(mockClock.isNowBefore(2L)).thenReturn(false);

Wait<WebDriver> wait = new FluentWait<WebDriver>(mockDriver, mockClock, mockSleeper)
Wait<WebDriver> wait = new FluentWait<>(mockDriver, mockClock, mockSleeper)
.withTimeout(0, TimeUnit.MILLISECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(AssertionError.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public OutOfProcessSeleniumServer start() {
String localAddress = new NetworkUtils().getPrivateLocalAddress();
baseUrl = String.format("http://%s:%d", localAddress, port);

List<String> cmdLine = new LinkedList<String>();
List<String> cmdLine = new LinkedList<>();
cmdLine.add("java");
cmdLine.add("-cp");
cmdLine.add(classPath);
Expand Down
2 changes: 1 addition & 1 deletion java/server/src/org/openqa/grid/internal/ProxySet.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@ThreadSafe
public class ProxySet implements Iterable<RemoteProxy> {

private final Set<RemoteProxy> proxies = new CopyOnWriteArraySet<RemoteProxy>();
private final Set<RemoteProxy> proxies = new CopyOnWriteArraySet<>();

private static final Logger log = Logger.getLogger(ProxySet.class.getName());
private volatile boolean throwOnCapabilityNotPresent = true;
Expand Down
2 changes: 1 addition & 1 deletion java/server/src/org/openqa/grid/internal/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Registry {
private final HttpClientFactory httpClientFactory;
private final NewSessionRequestQueue newSessionQueue;
private final Matcher matcherThread = new Matcher();
private final List<RemoteProxy> registeringProxies = new CopyOnWriteArrayList<RemoteProxy>();
private final List<RemoteProxy> registeringProxies = new CopyOnWriteArrayList<>();

private volatile boolean stop = false;
// The following three variables need to be volatile because we expose a public setters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public HtmlRenderer getHtmlRender() {
private volatile boolean poll = true;

// TODO freynaud
private List<RemoteException> errors = new CopyOnWriteArrayList<RemoteException>();
private List<RemoteException> errors = new CopyOnWriteArrayList<>();
private Thread pollingThread = null;

public boolean isAlive() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public int score(T value) {
}

static <T> CapabilityScorer<T> scoreAgainst(T value) {
return new CapabilityScorer<T>(value);
return new CapabilityScorer<>(value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private DefaultSession(final DriverFactory factory, TemporaryFilesystem tempFs,
this.clock = clock;
final BrowserCreator browserCreator = new BrowserCreator(factory, capabilities);
final FutureTask<EventFiringWebDriver> webDriverFutureTask =
new FutureTask<EventFiringWebDriver>(browserCreator);
new FutureTask<>(browserCreator);
executor = new ThreadPoolExecutor(1, 1,
600L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class JsonHttpCommandHandler {
private final Logger log;
private final JsonHttpCommandCodec commandCodec;
private final JsonHttpResponseCodec responseCodec;
private final Map<String, ResultConfig> configs = new LinkedHashMap<String, ResultConfig>();
private final Map<String, ResultConfig> configs = new LinkedHashMap<>();
private final ErrorCodes errorCodes = new ErrorCodes();

public JsonHttpCommandHandler(DriverSessions sessions, Logger log) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class SendKeys extends WebElementHandler<Void> implements JsonParametersAware {

private final List<CharSequence> keys = new CopyOnWriteArrayList<CharSequence>();
private final List<CharSequence> keys = new CopyOnWriteArrayList<>();

public SendKeys(Session session) {
super(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected WebDriverHandler(Session session) {

@Override
public final T handle() throws Exception {
FutureTask<T> future = new FutureTask<T>(this);
FutureTask<T> future = new FutureTask<>(this);
try {
return getSession().execute(future);
} catch (ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

public class SendKeyToActiveElement extends WebDriverHandler<Void> implements JsonParametersAware {

private final List<CharSequence> keys = new CopyOnWriteArrayList<CharSequence>();
private final List<CharSequence> keys = new CopyOnWriteArrayList<>();

public SendKeyToActiveElement(Session session) {
super(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public synchronized LogEntries getSessionLog(SessionId sessionId) throws IOExcep
public synchronized List<SessionId> getLoggedSessions() {
// TODO: Find a solution that can handle large numbers of sessions, maybe by
// reading them from disc.
ImmutableList.Builder<SessionId> builder = new ImmutableList.Builder<SessionId>();
ImmutableList.Builder<SessionId> builder = new ImmutableList.Builder<>();
builder.addAll(perSessionDriverEntries.keySet());
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public String decode(String string) {
}

public List decodeListOfStrings(List list) {
List<String> decodedList = new LinkedList<String>();
List<String> decodedList = new LinkedList<>();

for (Object o : list) {
decodedList.add(decode((String) o));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private Runnable getRunnableThatMakesSessionBusy(final Session session,
return new Runnable() {
public void run() {
try {
session.execute(new FutureTask<Object>(new Callable<Object>()
session.execute(new FutureTask<>(new Callable<Object>()
{
public Object call() {
try {
Expand Down

0 comments on commit cc6b935

Please sign in to comment.