Skip to content

Commit

Permalink
Java 7 generics empty parameters (diamond brackets)
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Inman-Semerau <luke.semerau@gmail.com>
  • Loading branch information
asashour authored and lukeis committed Jul 1, 2015
1 parent df012b8 commit f544b5b
Show file tree
Hide file tree
Showing 138 changed files with 345 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class BrowserConfigurationOptions {
public static final int DEFAULT_TIMEOUT_IN_SECONDS = 30 * 60; // identical to
// RemoteControlConfiguration;

private Map<String, String> options = new HashMap<String, String>();
private Map<String, String> options = new HashMap<>();

/**
* Instantiate a blank BrowserConfigurationOptions instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected void throwAssertionException(String message, Throwable throwable) {
private final class ContextImpl implements ConditionRunner.Context {

private final long start;
private List<String> info = new ArrayList<String>();
private List<String> info = new ArrayList<>();
private String lastInfo;

public ContextImpl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class JavascriptLibrary {

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

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

List<Object> args = new ArrayList<Object>();
List<Object> args = new ArrayList<>();
args.add(element);
args.addAll(Arrays.asList(values));

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

List<Object> args = new ArrayList<Object>();
List<Object> args = new ArrayList<>();
args.add(element);
args.addAll(Arrays.asList(values));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void selectWindowWithTitle(WebDriver driver, String title) {
public void selectBlankWindow(WebDriver driver) {
String current = driver.getWindowHandle();
// Find the first window without a "name" attribute
List<String> handles = new ArrayList<String>(driver.getWindowHandles());
List<String> handles = new ArrayList<>(driver.getWindowHandles());
for (String handle : handles) {
// the original window will never be a _blank window, so don't even look at it
// this is also important to skip, because the original/root window won't have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class GetAllButtons extends SeleneseCommand<String[]> {
@Override
protected String[] handleSeleneseCommand(WebDriver driver, String ignored, String alsoIgnored) {
List<WebElement> allInputs = driver.findElements(By.xpath("//input"));
List<String> ids = new ArrayList<String>();
List<String> ids = new ArrayList<>();

for (WebElement input : allInputs) {
String type = input.getAttribute("type").toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class GetAllFields extends SeleneseCommand<String[]> {
@Override
protected String[] handleSeleneseCommand(WebDriver driver, String locator, String value) {
List<WebElement> allInputs = driver.findElements(By.xpath("//input"));
List<String> ids = new ArrayList<String>();
List<String> ids = new ArrayList<>();

for (WebElement input : allInputs) {
String type = input.getAttribute("type").toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class GetAllLinks extends SeleneseCommand<String[]> {
@Override
protected String[] handleSeleneseCommand(WebDriver driver, String locator, String value) {
List<WebElement> allLinks = driver.findElements(By.xpath("//a"));
List<String> links = new ArrayList<String>();
List<String> links = new ArrayList<>();
for (WebElement link : allLinks) {
String id = link.getAttribute("id");
links.add(id == null ? "" : id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class GetAllWindowNames extends SeleneseCommand<String[]> {
protected String[] handleSeleneseCommand(WebDriver driver, String ignored, String alsoIgnored) {
String current = driver.getWindowHandle();

List<String> attributes = new ArrayList<String>();
List<String> attributes = new ArrayList<>();
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
attributes.add(((JavascriptExecutor) driver).executeScript("return window.name").toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class GetAllWindowTitles extends SeleneseCommand<String[]> {
protected String[] handleSeleneseCommand(WebDriver driver, String ignored, String alsoIgnored) {
String current = driver.getWindowHandle();

List<String> attributes = new ArrayList<String>();
List<String> attributes = new ArrayList<>();
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
attributes.add(driver.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class GetAttributeFromAllWindows extends SeleneseCommand<String[]> {
protected String[] handleSeleneseCommand(WebDriver driver, String attributeName, String ignored) {
String current = driver.getWindowHandle();

List<String> attributes = new ArrayList<String>();
List<String> attributes = new ArrayList<>();
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
String value = (String) ((JavascriptExecutor) driver).executeScript(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class WebDriverException extends RuntimeException {
public static final String SESSION_ID = "Session ID";
public static final String DRIVER_INFO = "Driver info";

private Map<String, String> extraInfo = new HashMap<String, String>();
private Map<String, String> extraInfo = new HashMap<>();

public WebDriverException() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected String extractAndCheck(File profileDir, String noFocusSoName,
// 3. Create a new LD_LIB_PATH string to contain:
// profile.getLibsDir32bit + ":" + profile.getLibsDir64bit

Set<String> pathsSet = new HashSet<String>();
Set<String> pathsSet = new HashSet<>();
pathsSet.add(jarPath32Bit);
pathsSet.add(jarPath64Bit);

Expand Down
24 changes: 12 additions & 12 deletions java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public void setProxySettings(Proxy proxy) {
switch (proxy.getProxyType()) {
case MANUAL:

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

} else if (arg instanceof Collection<?>) {
List<Object> list = new ArrayList<Object>();
List<Object> list = new ArrayList<>();
for (Object o : (Collection<?>) arg) {
list.add(parseArgumentIntoJavascriptParameter(context, scope, o));
}
return context.newArray(scope, list.toArray());

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

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

@Override
public List<WebElement> findElementsByLinkText(String selector) {
List<WebElement> elements = new ArrayList<WebElement>();
List<WebElement> elements = new ArrayList<>();

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

List<WebElement> toReturn = new ArrayList<WebElement>();
List<WebElement> toReturn = new ArrayList<>();

for (DomNode node : allNodes) {
if (node instanceof HtmlElement) {
Expand Down Expand Up @@ -1067,7 +1067,7 @@ public WebElement findElementByName(String name) {
@Override
public List<WebElement> findElementsByName(String using) {
if (!(lastPage() instanceof HtmlPage)) {
return new ArrayList<WebElement>();
return new ArrayList<>();
}

List<DomElement> allElements = ((HtmlPage) lastPage()).getElementsByName(using);
Expand All @@ -1091,11 +1091,11 @@ public WebElement findElementByTagName(String name) {
@Override
public List<WebElement> findElementsByTagName(String using) {
if (!(lastPage() instanceof HtmlPage)) {
return new ArrayList<WebElement>();
return new ArrayList<>();
}

NodeList allElements = ((HtmlPage) lastPage()).getElementsByTagName(using);
List<WebElement> toReturn = new ArrayList<WebElement>(allElements.getLength());
List<WebElement> toReturn = new ArrayList<>(allElements.getLength());
for (int i = 0; i < allElements.getLength(); i++) {
Node item = allElements.item(i);
if (item instanceof HtmlElement) {
Expand Down Expand Up @@ -1135,7 +1135,7 @@ public WebElement findElementByXPath(String selector) {
@Override
public List<WebElement> findElementsByXPath(String selector) {
if (!(lastPage() instanceof HtmlPage)) {
return new ArrayList<WebElement>();
return new ArrayList<>();
}

List<?> nodes;
Expand Down Expand Up @@ -1167,7 +1167,7 @@ public List<WebElement> findElementsByXPath(String selector) {
}

private List<WebElement> convertRawHtmlElementsToWebElements(List<?> nodes) {
List<WebElement> elements = new ArrayList<WebElement>();
List<WebElement> elements = new ArrayList<>();

for (Object node : nodes) {
if (node instanceof HtmlElement) {
Expand Down Expand Up @@ -1658,7 +1658,7 @@ public WebElement findElementByPartialLinkText(String using) {
@Override
public List<WebElement> findElementsByPartialLinkText(String using) {
List<HtmlAnchor> anchors = ((HtmlPage) lastPage()).getAnchors();
List<WebElement> elements = new ArrayList<WebElement>();
List<WebElement> elements = new ArrayList<>();
for (HtmlAnchor anchor : anchors) {
if (anchor.asText().contains(using)) {
elements.add(newHtmlUnitWebElement(anchor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void submit() {
private void submitForm(HtmlForm form) {
assertElementNotStale();

List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
names.add("input");
names.add("button");
List<? extends HtmlElement> allElements = form.getHtmlElementsByTagNames(names);
Expand Down Expand Up @@ -623,7 +623,7 @@ public List<WebElement> getElementsByTagName(String tagName) {
assertElementNotStale();

List<?> allChildren = element.getByXPath(".//" + tagName);
List<WebElement> elements = new ArrayList<WebElement>();
List<WebElement> elements = new ArrayList<>();
for (Object o : allChildren) {
if (!(o instanceof HtmlElement)) {
continue;
Expand Down Expand Up @@ -723,7 +723,7 @@ public WebElement findElementByXPath(String xpathExpr) {
public List<WebElement> findElementsByXPath(String xpathExpr) {
assertElementNotStale();

List<WebElement> webElements = new ArrayList<WebElement>();
List<WebElement> webElements = new ArrayList<>();

List<?> htmlElements;
try {
Expand Down Expand Up @@ -766,7 +766,7 @@ public List<WebElement> findElementsByLinkText(String linkText) {

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

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

List<HtmlElement> elements = element.getHtmlElementsByTagName(name);
List<WebElement> toReturn = new ArrayList<WebElement>(elements.size());
List<WebElement> toReturn = new ArrayList<>(elements.size());
for (HtmlElement element : elements) {
toReturn.add(parent.newHtmlUnitWebElement(element));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class CompositeAction implements Action {
private WebDriver driver;
private List<Action> actionsList = new ArrayList<Action>();
private List<Action> actionsList = new ArrayList<>();

public CompositeAction() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void perform() {
}

public List<Action> getActions() {
List<Action> actions = new ArrayList<Action>();
List<Action> actions = new ArrayList<>();
for (CharSequence chars : keysToSend) {
for (int i = 0; i < chars.length(); i++) {
Keys key = Keys.getKeyFromUnicode(chars.charAt(i));
Expand Down
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/lift/find/BaseFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public abstract class BaseFinder<S, T> implements Finder<S, T> {

protected List<Matcher<S>> matchers = new ArrayList<Matcher<S>>();
protected List<Matcher<S>> matchers = new ArrayList<>();

public Collection<S> findFrom(T context) {

Expand Down Expand Up @@ -64,7 +64,7 @@ public void describeTo(Description description) {
protected abstract void describeTargetTo(Description description);

protected Collection<S> allMatching(List<Matcher<S>> matchers, Collection<S> items) {
Collection<S> temp = new ArrayList<S>();
Collection<S> temp = new ArrayList<>();
for (S item : items) {
if (allOf(matchers).matches(item)) {
temp.add(item);
Expand Down
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/logging/LogEntries.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LogEntries implements Iterable<LogEntry> {
private final List<LogEntry> entries;

public LogEntries(Iterable<LogEntry> entries) {
List<LogEntry> mutableEntries = new ArrayList<LogEntry>();
List<LogEntry> mutableEntries = new ArrayList<>();
for (LogEntry entry : entries) {
mutableEntries.add(entry);
}
Expand All @@ -56,7 +56,7 @@ public List<LogEntry> getAll() {
* @return all log entries for that level and above
*/
public List<LogEntry> filter(Level level) {
List<LogEntry> toReturn = new ArrayList<LogEntry>();
List<LogEntry> toReturn = new ArrayList<>();

for (LogEntry entry : entries) {
if (entry.getLevel().intValue() >= level.intValue()) {
Expand Down
2 changes: 1 addition & 1 deletion java/client/src/org/openqa/selenium/logging/LogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public String toString() {
}

public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("timestamp", timestamp);
map.put("level", level);
map.put("message", message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class LoggingPreferences implements Serializable {
private static final long serialVersionUID = 6708028456766320675L;

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SessionLogHandler {
* @return The session logs mapped to session IDs.
*/
public static Map<String, SessionLogs> getSessionLogs(JsonObject rawSessionMap) {
Map<String, SessionLogs> sessionLogsMap = new HashMap<String, SessionLogs>();
Map<String, SessionLogs> sessionLogsMap = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : rawSessionMap.entrySet()) {
String sessionId = entry.getKey();
SessionLogs sessionLogs = SessionLogs.fromJSON(entry.getValue().getAsJsonObject());
Expand Down
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/logging/SessionLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SessionLogs {
private final Map<String, LogEntries> logTypeToEntriesMap;

public SessionLogs() {
this.logTypeToEntriesMap = new HashMap<String, LogEntries>();
this.logTypeToEntriesMap = new HashMap<>();
}

public LogEntries getLogs(String logType) {
Expand All @@ -65,7 +65,7 @@ public static SessionLogs fromJSON(JsonObject rawSessionLogs) {
for (Map.Entry<String, JsonElement> entry : rawSessionLogs.entrySet()) {
String logType = entry.getKey();
JsonArray rawLogEntries = entry.getValue().getAsJsonArray();
List<LogEntry> logEntries = new ArrayList<LogEntry>();
List<LogEntry> logEntries = new ArrayList<>();
for (int index = 0; index < rawLogEntries.size(); index++) {
JsonObject rawEntry = rawLogEntries.get(index).getAsJsonObject();
logEntries.add(new LogEntry(LogLevelMapping.toLevel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public DefaultNetworkInterfaceProvider() {
throw new WebDriverException(e);
}

List<NetworkInterface> result = new ArrayList<NetworkInterface>();
List<NetworkInterface> result = new ArrayList<>();
while (interfaces.hasMoreElements()) {
result.add(createInterface(interfaces.nextElement()));
}
Expand Down
Loading

0 comments on commit f544b5b

Please sign in to comment.