Replaced Collection.size() > 0 through !Collection.isEmpty()

This commit is contained in:
Patrick Gotthard 2014-04-13 20:29:52 +02:00
parent 9bf5a75e2c
commit 5926dd2bd2
10 changed files with 19 additions and 19 deletions

View file

@ -208,7 +208,7 @@ public class ClientCollection extends Collection {
}
final List<Element> acceptElems = element.getChildren("accept", AtomService.ATOM_PROTOCOL);
if (acceptElems != null && acceptElems.size() > 0) {
if (acceptElems != null && !acceptElems.isEmpty()) {
for (final Element acceptElem : acceptElems) {
addAccept(acceptElem.getTextTrim());
}

View file

@ -104,7 +104,7 @@ public class ClientEntry extends Entry {
* one content element per entry.
*/
public Content getContent() {
if (getContents() != null && getContents().size() > 0) {
if (getContents() != null && !getContents().isEmpty()) {
final Content c = getContents().get(0);
return c;
}

View file

@ -156,7 +156,7 @@ public class ClientMediaEntry extends ClientEntry {
* resource data as an InputStream or as a byte array.
*/
public InputStream getAsStream() throws ProponoException {
if (getContents() != null && getContents().size() > 0) {
if (getContents() != null && !getContents().isEmpty()) {
final Content c = getContents().get(0);
if (c.getSrc() != null) {
return getResourceAsStream();

View file

@ -241,7 +241,7 @@ public class Collection {
}
final List<Element> acceptElems = element.getChildren("accept", AtomService.ATOM_PROTOCOL);
if (acceptElems != null && acceptElems.size() > 0) {
if (acceptElems != null && !acceptElems.isEmpty()) {
for (final Element acceptElem : acceptElems) {
addAccept(acceptElem.getTextTrim());
}

View file

@ -151,7 +151,7 @@ public class AtomEntry extends BaseBlogEntry implements BlogEntry {
}
final List<com.sun.syndication.feed.atom.Content> contents = entry.getContents();
com.sun.syndication.feed.atom.Content romeContent = null;
if (contents != null && contents.size() > 0) {
if (contents != null && !contents.isEmpty()) {
romeContent = contents.get(0);
}
if (romeContent != null) {
@ -172,7 +172,7 @@ public class AtomEntry extends BaseBlogEntry implements BlogEntry {
categories = cats;
}
final List<SyndPerson> authors = entry.getAuthors();
if (authors != null && authors.size() > 0) {
if (authors != null && !authors.isEmpty()) {
final com.sun.syndication.feed.atom.Person romeAuthor = (com.sun.syndication.feed.atom.Person) authors.get(0);
if (romeAuthor != null) {
author = new Person();

View file

@ -106,7 +106,7 @@ public class MetaWeblogEntry extends BaseBlogEntry {
if (getContent() != null && getContent().getValue() != null) {
struct.put("description", getContent().getValue());
}
if (getCategories() != null && getCategories().size() > 0) {
if (getCategories() != null && !getCategories().isEmpty()) {
final List<String> catArray = new ArrayList<String>();
final List<Category> cats = getCategories();
for (int i = 0; i < cats.size(); i++) {

View file

@ -115,7 +115,7 @@ public class AtomClientTest extends TestCase {
*/
public void testGetAtomService() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
assertNotNull(space.getTitle());
@ -135,7 +135,7 @@ public class AtomClientTest extends TestCase {
*/
public void testSimpleEntryPostAndRemove() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
@ -183,7 +183,7 @@ public class AtomClientTest extends TestCase {
*/
public void testSimpleEntryPostUpdateAndRemove() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
@ -266,7 +266,7 @@ public class AtomClientTest extends TestCase {
*/
public void testEntryPostWithCategories() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element2 : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element2;
@ -359,7 +359,7 @@ public class AtomClientTest extends TestCase {
*/
public void testMediaPost() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;

View file

@ -69,7 +69,7 @@ public class AtomServiceTest extends TestCase {
assertNotNull(col.getTitle());
assertNotNull(col.getHrefResolved());
int catCount = 0;
if (col.getCategories().size() > 0) {
if (!col.getCategories().isEmpty()) {
for (final Object element3 : col.getCategories()) {
final Categories cats = (Categories) element3;
catCount += cats.getCategories().size();

View file

@ -147,7 +147,7 @@ public class AtomClientServerTest {
@Test
public void testGetAtomService() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
for (final Workspace workspace : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) workspace;
assertNotNull(space.getTitle());
@ -168,7 +168,7 @@ public class AtomClientServerTest {
@Test
public void testSimpleEntryPostAndRemove() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
@ -217,7 +217,7 @@ public class AtomClientServerTest {
@Test
public void testSimpleEntryPostUpdateAndRemove() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;
@ -302,7 +302,7 @@ public class AtomClientServerTest {
@Test
public void testEntryPostWithCategories() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element2 : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element2;
@ -395,7 +395,7 @@ public class AtomClientServerTest {
*/
public void testMediaPost() throws Exception {
assertNotNull(service);
assertTrue(service.getWorkspaces().size() > 0);
assertTrue(!service.getWorkspaces().isEmpty());
int count = 0;
for (final Object element : service.getWorkspaces()) {
final ClientWorkspace space = (ClientWorkspace) element;

View file

@ -130,7 +130,7 @@ public class SimpleBlogClientTest extends TestCase {
final BlogConnection conn = BlogConnectionFactory.getBlogConnection(type, endpoint, username, password);
assertNotNull(conn);
assertTrue(conn.getBlogs().size() > 0);
assertTrue(!conn.getBlogs().isEmpty());
int count = 0;
for (final Blog blog2 : conn.getBlogs()) {
final Blog blog = blog2;