Skip to content

Commit f544b5b

Browse files
asashourlukeis
authored andcommitted
Java 7 generics empty parameters (diamond brackets)
Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent df012b8 commit f544b5b

File tree

138 files changed

+345
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+345
-348
lines changed

java/client/src/com/thoughtworks/selenium/BrowserConfigurationOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class BrowserConfigurationOptions {
4343
public static final int DEFAULT_TIMEOUT_IN_SECONDS = 30 * 60; // identical to
4444
// RemoteControlConfiguration;
4545

46-
private Map<String, String> options = new HashMap<String, String>();
46+
private Map<String, String> options = new HashMap<>();
4747

4848
/**
4949
* Instantiate a blank BrowserConfigurationOptions instance.

java/client/src/com/thoughtworks/selenium/condition/DefaultConditionRunner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ protected void throwAssertionException(String message, Throwable throwable) {
208208
private final class ContextImpl implements ConditionRunner.Context {
209209

210210
private final long start;
211-
private List<String> info = new ArrayList<String>();
211+
private List<String> info = new ArrayList<>();
212212
private String lastInfo;
213213

214214
public ContextImpl() {

java/client/src/com/thoughtworks/selenium/webdriven/JavascriptLibrary.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class JavascriptLibrary {
3636

3737
static final String PREFIX = "/" + JavascriptLibrary.class.getPackage()
3838
.getName().replace(".", "/") + "/";
39-
private final ConcurrentHashMap<String, String> scripts = new ConcurrentHashMap<String, String>();
39+
private final ConcurrentHashMap<String, String> scripts = new ConcurrentHashMap<>();
4040

4141
private static final String injectableSelenium =
4242
"/com/thoughtworks/selenium/webdriven/injectableSelenium.js";
@@ -62,7 +62,7 @@ public void callEmbeddedSelenium(WebDriver driver, String functionName,
6262
builder.append("return browserbot.").append(functionName)
6363
.append(".apply(browserbot, arguments);");
6464

65-
List<Object> args = new ArrayList<Object>();
65+
List<Object> args = new ArrayList<>();
6666
args.add(element);
6767
args.addAll(Arrays.asList(values));
6868

@@ -76,7 +76,7 @@ public Object callEmbeddedHtmlUtils(WebDriver driver, String functionName, WebEl
7676
builder.append("return htmlutils.").append(functionName)
7777
.append(".apply(htmlutils, arguments);");
7878

79-
List<Object> args = new ArrayList<Object>();
79+
List<Object> args = new ArrayList<>();
8080
args.add(element);
8181
args.addAll(Arrays.asList(values));
8282

java/client/src/com/thoughtworks/selenium/webdriven/Windows.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private void selectWindowWithTitle(WebDriver driver, String title) {
155155
public void selectBlankWindow(WebDriver driver) {
156156
String current = driver.getWindowHandle();
157157
// Find the first window without a "name" attribute
158-
List<String> handles = new ArrayList<String>(driver.getWindowHandles());
158+
List<String> handles = new ArrayList<>(driver.getWindowHandles());
159159
for (String handle : handles) {
160160
// the original window will never be a _blank window, so don't even look at it
161161
// this is also important to skip, because the original/root window won't have

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetAllButtons.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GetAllButtons extends SeleneseCommand<String[]> {
3030
@Override
3131
protected String[] handleSeleneseCommand(WebDriver driver, String ignored, String alsoIgnored) {
3232
List<WebElement> allInputs = driver.findElements(By.xpath("//input"));
33-
List<String> ids = new ArrayList<String>();
33+
List<String> ids = new ArrayList<>();
3434

3535
for (WebElement input : allInputs) {
3636
String type = input.getAttribute("type").toLowerCase();

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetAllFields.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GetAllFields extends SeleneseCommand<String[]> {
3030
@Override
3131
protected String[] handleSeleneseCommand(WebDriver driver, String locator, String value) {
3232
List<WebElement> allInputs = driver.findElements(By.xpath("//input"));
33-
List<String> ids = new ArrayList<String>();
33+
List<String> ids = new ArrayList<>();
3434

3535
for (WebElement input : allInputs) {
3636
String type = input.getAttribute("type").toLowerCase();

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetAllLinks.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GetAllLinks extends SeleneseCommand<String[]> {
3030
@Override
3131
protected String[] handleSeleneseCommand(WebDriver driver, String locator, String value) {
3232
List<WebElement> allLinks = driver.findElements(By.xpath("//a"));
33-
List<String> links = new ArrayList<String>();
33+
List<String> links = new ArrayList<>();
3434
for (WebElement link : allLinks) {
3535
String id = link.getAttribute("id");
3636
links.add(id == null ? "" : id);

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetAllWindowNames.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GetAllWindowNames extends SeleneseCommand<String[]> {
3030
protected String[] handleSeleneseCommand(WebDriver driver, String ignored, String alsoIgnored) {
3131
String current = driver.getWindowHandle();
3232

33-
List<String> attributes = new ArrayList<String>();
33+
List<String> attributes = new ArrayList<>();
3434
for (String handle : driver.getWindowHandles()) {
3535
driver.switchTo().window(handle);
3636
attributes.add(((JavascriptExecutor) driver).executeScript("return window.name").toString());

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetAllWindowTitles.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class GetAllWindowTitles extends SeleneseCommand<String[]> {
2929
protected String[] handleSeleneseCommand(WebDriver driver, String ignored, String alsoIgnored) {
3030
String current = driver.getWindowHandle();
3131

32-
List<String> attributes = new ArrayList<String>();
32+
List<String> attributes = new ArrayList<>();
3333
for (String handle : driver.getWindowHandles()) {
3434
driver.switchTo().window(handle);
3535
attributes.add(driver.getTitle());

java/client/src/com/thoughtworks/selenium/webdriven/commands/GetAttributeFromAllWindows.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GetAttributeFromAllWindows extends SeleneseCommand<String[]> {
3030
protected String[] handleSeleneseCommand(WebDriver driver, String attributeName, String ignored) {
3131
String current = driver.getWindowHandle();
3232

33-
List<String> attributes = new ArrayList<String>();
33+
List<String> attributes = new ArrayList<>();
3434
for (String handle : driver.getWindowHandles()) {
3535
driver.switchTo().window(handle);
3636
String value = (String) ((JavascriptExecutor) driver).executeScript(

java/client/src/org/openqa/selenium/WebDriverException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class WebDriverException extends RuntimeException {
2929
public static final String SESSION_ID = "Session ID";
3030
public static final String DRIVER_INFO = "Driver info";
3131

32-
private Map<String, String> extraInfo = new HashMap<String, String>();
32+
private Map<String, String> extraInfo = new HashMap<>();
3333

3434
public WebDriverException() {
3535
super();

java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected String extractAndCheck(File profileDir, String noFocusSoName,
150150
// 3. Create a new LD_LIB_PATH string to contain:
151151
// profile.getLibsDir32bit + ":" + profile.getLibsDir64bit
152152

153-
Set<String> pathsSet = new HashSet<String>();
153+
Set<String> pathsSet = new HashSet<>();
154154
pathsSet.add(jarPath32Bit);
155155
pathsSet.add(jarPath64Bit);
156156

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public void setProxySettings(Proxy proxy) {
349349
switch (proxy.getProxyType()) {
350350
case MANUAL:
351351

352-
ArrayList<String> noProxyHosts = new ArrayList<String>();
352+
ArrayList<String> noProxyHosts = new ArrayList<>();
353353
String noProxy = proxy.getNoProxy();
354354
if (noProxy != null && !noProxy.equals("")) {
355355
String[] hosts = noProxy.split(",");
@@ -735,14 +735,14 @@ private Object parseArgumentIntoJavascriptParameter(
735735
return element.getScriptObject();
736736

737737
} else if (arg instanceof Collection<?>) {
738-
List<Object> list = new ArrayList<Object>();
738+
List<Object> list = new ArrayList<>();
739739
for (Object o : (Collection<?>) arg) {
740740
list.add(parseArgumentIntoJavascriptParameter(context, scope, o));
741741
}
742742
return context.newArray(scope, list.toArray());
743743

744744
} else if (arg.getClass().isArray()) {
745-
List<Object> list = new ArrayList<Object>();
745+
List<Object> list = new ArrayList<>();
746746
for (Object o : (Object[]) arg) {
747747
list.add(parseArgumentIntoJavascriptParameter(context, scope, o));
748748
}
@@ -899,7 +899,7 @@ private Map<String, Object> convertLocationToMap(Location location) {
899899
}
900900

901901
private List<Object> parseJavascriptResultsList(JavaScriptResultsCollection array) {
902-
List<Object> list = new ArrayList<Object>(array.getLength());
902+
List<Object> list = new ArrayList<>(array.getLength());
903903
for (int i = 0; i < array.getLength(); ++i) {
904904
list.add(parseNativeJavascriptResult(array.item(i)));
905905
}
@@ -951,7 +951,7 @@ protected WebElement newHtmlUnitWebElement(HtmlElement element) {
951951

952952
@Override
953953
public List<WebElement> findElementsByLinkText(String selector) {
954-
List<WebElement> elements = new ArrayList<WebElement>();
954+
List<WebElement> elements = new ArrayList<>();
955955

956956
if (!(lastPage() instanceof HtmlPage)) {
957957
return elements;
@@ -1037,7 +1037,7 @@ public List<WebElement> findElementsByCssSelector(String using) {
10371037
throw new NoSuchElementException("Unable to locate element using css", ex);
10381038
}
10391039

1040-
List<WebElement> toReturn = new ArrayList<WebElement>();
1040+
List<WebElement> toReturn = new ArrayList<>();
10411041

10421042
for (DomNode node : allNodes) {
10431043
if (node instanceof HtmlElement) {
@@ -1067,7 +1067,7 @@ public WebElement findElementByName(String name) {
10671067
@Override
10681068
public List<WebElement> findElementsByName(String using) {
10691069
if (!(lastPage() instanceof HtmlPage)) {
1070-
return new ArrayList<WebElement>();
1070+
return new ArrayList<>();
10711071
}
10721072

10731073
List<DomElement> allElements = ((HtmlPage) lastPage()).getElementsByName(using);
@@ -1091,11 +1091,11 @@ public WebElement findElementByTagName(String name) {
10911091
@Override
10921092
public List<WebElement> findElementsByTagName(String using) {
10931093
if (!(lastPage() instanceof HtmlPage)) {
1094-
return new ArrayList<WebElement>();
1094+
return new ArrayList<>();
10951095
}
10961096

10971097
NodeList allElements = ((HtmlPage) lastPage()).getElementsByTagName(using);
1098-
List<WebElement> toReturn = new ArrayList<WebElement>(allElements.getLength());
1098+
List<WebElement> toReturn = new ArrayList<>(allElements.getLength());
10991099
for (int i = 0; i < allElements.getLength(); i++) {
11001100
Node item = allElements.item(i);
11011101
if (item instanceof HtmlElement) {
@@ -1135,7 +1135,7 @@ public WebElement findElementByXPath(String selector) {
11351135
@Override
11361136
public List<WebElement> findElementsByXPath(String selector) {
11371137
if (!(lastPage() instanceof HtmlPage)) {
1138-
return new ArrayList<WebElement>();
1138+
return new ArrayList<>();
11391139
}
11401140

11411141
List<?> nodes;
@@ -1167,7 +1167,7 @@ public List<WebElement> findElementsByXPath(String selector) {
11671167
}
11681168

11691169
private List<WebElement> convertRawHtmlElementsToWebElements(List<?> nodes) {
1170-
List<WebElement> elements = new ArrayList<WebElement>();
1170+
List<WebElement> elements = new ArrayList<>();
11711171

11721172
for (Object node : nodes) {
11731173
if (node instanceof HtmlElement) {
@@ -1658,7 +1658,7 @@ public WebElement findElementByPartialLinkText(String using) {
16581658
@Override
16591659
public List<WebElement> findElementsByPartialLinkText(String using) {
16601660
List<HtmlAnchor> anchors = ((HtmlPage) lastPage()).getAnchors();
1661-
List<WebElement> elements = new ArrayList<WebElement>();
1661+
List<WebElement> elements = new ArrayList<>();
16621662
for (HtmlAnchor anchor : anchors) {
16631663
if (anchor.asText().contains(using)) {
16641664
elements.add(newHtmlUnitWebElement(anchor));

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void submit() {
190190
private void submitForm(HtmlForm form) {
191191
assertElementNotStale();
192192

193-
List<String> names = new ArrayList<String>();
193+
List<String> names = new ArrayList<>();
194194
names.add("input");
195195
names.add("button");
196196
List<? extends HtmlElement> allElements = form.getHtmlElementsByTagNames(names);
@@ -623,7 +623,7 @@ public List<WebElement> getElementsByTagName(String tagName) {
623623
assertElementNotStale();
624624

625625
List<?> allChildren = element.getByXPath(".//" + tagName);
626-
List<WebElement> elements = new ArrayList<WebElement>();
626+
List<WebElement> elements = new ArrayList<>();
627627
for (Object o : allChildren) {
628628
if (!(o instanceof HtmlElement)) {
629629
continue;
@@ -723,7 +723,7 @@ public WebElement findElementByXPath(String xpathExpr) {
723723
public List<WebElement> findElementsByXPath(String xpathExpr) {
724724
assertElementNotStale();
725725

726-
List<WebElement> webElements = new ArrayList<WebElement>();
726+
List<WebElement> webElements = new ArrayList<>();
727727

728728
List<?> htmlElements;
729729
try {
@@ -766,7 +766,7 @@ public List<WebElement> findElementsByLinkText(String linkText) {
766766

767767
String expectedText = linkText.trim();
768768
List<? extends HtmlElement> htmlElements = element.getHtmlElementsByTagName("a");
769-
List<WebElement> webElements = new ArrayList<WebElement>();
769+
List<WebElement> webElements = new ArrayList<>();
770770
for (HtmlElement e : htmlElements) {
771771
if (expectedText.equals(e.getTextContent().trim()) && e.getAttribute("href") != null) {
772772
webElements.add(getParent().newHtmlUnitWebElement(e));
@@ -792,7 +792,7 @@ public List<WebElement> findElementsByPartialLinkText(String linkText) {
792792
assertElementNotStale();
793793

794794
List<? extends HtmlElement> htmlElements = element.getHtmlElementsByTagName("a");
795-
List<WebElement> webElements = new ArrayList<WebElement>();
795+
List<WebElement> webElements = new ArrayList<>();
796796
for (HtmlElement e : htmlElements) {
797797
if (e.getTextContent().contains(linkText)
798798
&& e.getAttribute("href") != null) {
@@ -818,7 +818,7 @@ public List<WebElement> findElementsByTagName(String name) {
818818
assertElementNotStale();
819819

820820
List<HtmlElement> elements = element.getHtmlElementsByTagName(name);
821-
List<WebElement> toReturn = new ArrayList<WebElement>(elements.size());
821+
List<WebElement> toReturn = new ArrayList<>(elements.size());
822822
for (HtmlElement element : elements) {
823823
toReturn.add(parent.newHtmlUnitWebElement(element));
824824
}

java/client/src/org/openqa/selenium/interactions/CompositeAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public class CompositeAction implements Action {
3434
private WebDriver driver;
35-
private List<Action> actionsList = new ArrayList<Action>();
35+
private List<Action> actionsList = new ArrayList<>();
3636

3737
public CompositeAction() {
3838
}

java/client/src/org/openqa/selenium/interactions/SendKeysAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void perform() {
5050
}
5151

5252
public List<Action> getActions() {
53-
List<Action> actions = new ArrayList<Action>();
53+
List<Action> actions = new ArrayList<>();
5454
for (CharSequence chars : keysToSend) {
5555
for (int i = 0; i < chars.length(); i++) {
5656
Keys key = Keys.getKeyFromUnicode(chars.charAt(i));

java/client/src/org/openqa/selenium/lift/find/BaseFinder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
public abstract class BaseFinder<S, T> implements Finder<S, T> {
3333

34-
protected List<Matcher<S>> matchers = new ArrayList<Matcher<S>>();
34+
protected List<Matcher<S>> matchers = new ArrayList<>();
3535

3636
public Collection<S> findFrom(T context) {
3737

@@ -64,7 +64,7 @@ public void describeTo(Description description) {
6464
protected abstract void describeTargetTo(Description description);
6565

6666
protected Collection<S> allMatching(List<Matcher<S>> matchers, Collection<S> items) {
67-
Collection<S> temp = new ArrayList<S>();
67+
Collection<S> temp = new ArrayList<>();
6868
for (S item : items) {
6969
if (allOf(matchers).matches(item)) {
7070
temp.add(item);

java/client/src/org/openqa/selenium/logging/LogEntries.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class LogEntries implements Iterable<LogEntry> {
3535
private final List<LogEntry> entries;
3636

3737
public LogEntries(Iterable<LogEntry> entries) {
38-
List<LogEntry> mutableEntries = new ArrayList<LogEntry>();
38+
List<LogEntry> mutableEntries = new ArrayList<>();
3939
for (LogEntry entry : entries) {
4040
mutableEntries.add(entry);
4141
}
@@ -56,7 +56,7 @@ public List<LogEntry> getAll() {
5656
* @return all log entries for that level and above
5757
*/
5858
public List<LogEntry> filter(Level level) {
59-
List<LogEntry> toReturn = new ArrayList<LogEntry>();
59+
List<LogEntry> toReturn = new ArrayList<>();
6060

6161
for (LogEntry entry : entries) {
6262
if (entry.getLevel().intValue() >= level.intValue()) {

java/client/src/org/openqa/selenium/logging/LogEntry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public String toString() {
8585
}
8686

8787
public Map<String, Object> toMap() {
88-
Map<String, Object> map = new HashMap<String, Object>();
88+
Map<String, Object> map = new HashMap<>();
8989
map.put("timestamp", timestamp);
9090
map.put("level", level);
9191
map.put("message", message);

java/client/src/org/openqa/selenium/logging/LoggingPreferences.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class LoggingPreferences implements Serializable {
4040
private static final long serialVersionUID = 6708028456766320675L;
4141

4242
// Mapping the {@link LogType} to {@link Level}
43-
private final Map<String, Level> prefs = new HashMap<String, Level>();
43+
private final Map<String, Level> prefs = new HashMap<>();
4444

4545
/**
4646
* Enables logging for the given log type at the specified level and above.
@@ -55,7 +55,7 @@ public void enable(String logType, Level level) {
5555
* @return the set of log types for which logging has been enabled.
5656
*/
5757
public Set<String> getEnabledLogTypes() {
58-
return new HashSet<String>(prefs.keySet());
58+
return new HashSet<>(prefs.keySet());
5959
}
6060

6161
/**

java/client/src/org/openqa/selenium/logging/SessionLogHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class SessionLogHandler {
3333
* @return The session logs mapped to session IDs.
3434
*/
3535
public static Map<String, SessionLogs> getSessionLogs(JsonObject rawSessionMap) {
36-
Map<String, SessionLogs> sessionLogsMap = new HashMap<String, SessionLogs>();
36+
Map<String, SessionLogs> sessionLogsMap = new HashMap<>();
3737
for (Map.Entry<String, JsonElement> entry : rawSessionMap.entrySet()) {
3838
String sessionId = entry.getKey();
3939
SessionLogs sessionLogs = SessionLogs.fromJSON(entry.getValue().getAsJsonObject());

java/client/src/org/openqa/selenium/logging/SessionLogs.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class SessionLogs {
3838
private final Map<String, LogEntries> logTypeToEntriesMap;
3939

4040
public SessionLogs() {
41-
this.logTypeToEntriesMap = new HashMap<String, LogEntries>();
41+
this.logTypeToEntriesMap = new HashMap<>();
4242
}
4343

4444
public LogEntries getLogs(String logType) {
@@ -65,7 +65,7 @@ public static SessionLogs fromJSON(JsonObject rawSessionLogs) {
6565
for (Map.Entry<String, JsonElement> entry : rawSessionLogs.entrySet()) {
6666
String logType = entry.getKey();
6767
JsonArray rawLogEntries = entry.getValue().getAsJsonArray();
68-
List<LogEntry> logEntries = new ArrayList<LogEntry>();
68+
List<LogEntry> logEntries = new ArrayList<>();
6969
for (int index = 0; index < rawLogEntries.size(); index++) {
7070
JsonObject rawEntry = rawLogEntries.get(index).getAsJsonObject();
7171
logEntries.add(new LogEntry(LogLevelMapping.toLevel(

java/client/src/org/openqa/selenium/net/DefaultNetworkInterfaceProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public DefaultNetworkInterfaceProvider() {
4747
throw new WebDriverException(e);
4848
}
4949

50-
List<NetworkInterface> result = new ArrayList<NetworkInterface>();
50+
List<NetworkInterface> result = new ArrayList<>();
5151
while (interfaces.hasMoreElements()) {
5252
result.add(createInterface(interfaces.nextElement()));
5353
}

0 commit comments

Comments
 (0)