Skip to content

Commit

Permalink
Merge pull request #70 from DevFactory/release/general-code-quality-f…
Browse files Browse the repository at this point in the history
…ix-1

Prefer isEmpty to size==0; extra null check; prefer <> operator
  • Loading branch information
alechenninger committed Mar 29, 2016
2 parents d074b3a + cee23b1 commit 71485a4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public <T> List<T> findAllByView(Class<T> type, View view) {
+ "available frames.");
}

return (List<T>) new LazyList<Browser>(new FoundByViewSupplier(view));
return (List<T>) new LazyList<>(new FoundByViewSupplier(view));
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -161,7 +161,7 @@ public <T> List<T> findAllByTitle(Class<T> type, String title) {
+ "available frames.");
}

return (List<T>) new LazyList<Browser>(new FoundByTitleSupplier(title));
return (List<T>) new LazyList<>(new FoundByTitleSupplier(title));
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -190,7 +190,7 @@ public <T> List<T> findAllByUrl(Class<T> type, Matcher<? super String> urlMatche
+ "available frames.");
}

return (List<T>) new LazyList<Browser>(new FoundByUrlSupplier(urlMatcher));
return (List<T>) new LazyList<>(new FoundByUrlSupplier(urlMatcher));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public List<WebElement> findElements(SearchContext context) {
}
}

return found.stream()
return found == null ? null : found.stream()
.map(WebDriverElement::getWrappedElement)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ByVisibleText(String text) {

@Override
public List<WebElement> findElements(SearchContext context) {
List<WebElement> result = new ArrayList<WebElement>();
List<WebElement> result = new ArrayList<>();

// First find any elements that *contain* this text.
List<WebElement> elems = byPartialVisibleText.findElements(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ByVisibleTextIgnoreCase(String text) {

@Override
public List<WebElement> findElements(SearchContext context) {
List<WebElement> result = new ArrayList<WebElement>();
List<WebElement> result = new ArrayList<>();

// First find any elements that *contain* this text.
List<WebElement> elems = byPartialVisibleTextIgnoreCase.findElements(context);
Expand All @@ -60,7 +60,7 @@ public List<WebElement> findElements(SearchContext context) {
}
}

if (result.size() == 0) {
if (result.isEmpty()) {
throw new NoSuchElementException("Cannot locate an element using "
+ toString());
}
Expand Down

0 comments on commit 71485a4

Please sign in to comment.