Refactored ternary operators

This commit is contained in:
Patrick Gotthard 2013-10-04 10:06:06 +02:00
parent b43bbb8bb2
commit 1249adbaf9
21 changed files with 459 additions and 108 deletions

View file

@ -195,7 +195,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
*/ */
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules; if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
} }
/** /**
@ -231,7 +234,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Element> getForeignMarkup() { public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup; if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
} }
/** /**

View file

@ -146,7 +146,11 @@ public class Category implements Cloneable, Serializable {
} }
public String getSchemeResolved() { public String getSchemeResolved() {
return schemeResolved != null ? schemeResolved : scheme; if (schemeResolved != null) {
return schemeResolved;
} else {
return scheme;
}
} }
/** /**

View file

@ -83,7 +83,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* list if none. * list if none.
*/ */
public List<Link> getAlternateLinks() { public List<Link> getAlternateLinks() {
return alternateLinks == null ? (alternateLinks = new ArrayList<Link>()) : alternateLinks; if (alternateLinks == null) {
alternateLinks = new ArrayList<Link>();
}
return alternateLinks;
} }
/** /**
@ -105,7 +108,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Person> getAuthors() { public List<Person> getAuthors() {
return authors == null ? (authors = new ArrayList<Person>()) : authors; if (authors == null) {
authors = new ArrayList<Person>();
}
return authors;
} }
/** /**
@ -127,7 +133,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @since Atom 1.0 * @since Atom 1.0
*/ */
public List<Category> getCategories() { public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories; if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
} }
/** /**
@ -149,7 +158,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* if none. * if none.
*/ */
public List<Content> getContents() { public List<Content> getContents() {
return contents == null ? (contents = new ArrayList<Content>()) : contents; if (contents == null) {
contents = new ArrayList<Content>();
}
return contents;
} }
/** /**
@ -173,7 +185,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Person> getContributors() { public List<Person> getContributors() {
return contributors == null ? (contributors = new ArrayList<Person>()) : contributors; if (contributors == null) {
contributors = new ArrayList<Person>();
}
return contributors;
} }
/** /**
@ -193,7 +208,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @return the entry created date, <b>null</b> if none. * @return the entry created date, <b>null</b> if none.
*/ */
public Date getCreated() { public Date getCreated() {
return created == null ? null : new Date(created.getTime()); if (created == null) {
return null;
} else {
return new Date(created.getTime());
}
} }
/** /**
@ -215,7 +234,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Element> getForeignMarkup() { public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup; if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
} }
/** /**
@ -259,7 +281,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @return the entry issued date, <b>null</b> if none. * @return the entry issued date, <b>null</b> if none.
*/ */
public Date getIssued() { public Date getIssued() {
return published == null ? null : new Date(published.getTime()); if (published == null) {
return null;
} else {
return new Date(published.getTime());
}
} }
/** /**
@ -301,7 +327,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @return the entry modified date, <b>null</b> if none. * @return the entry modified date, <b>null</b> if none.
*/ */
public Date getModified() { public Date getModified() {
return updated == null ? null : new Date(updated.getTime()); if (updated == null) {
return null;
} else {
return new Date(updated.getTime());
}
} }
/** /**
@ -339,7 +369,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
*/ */
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules; if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
} }
/** /**
@ -361,7 +394,10 @@ public class Entry implements Cloneable, Serializable, Extendable {
* set, an empty list if none. * set, an empty list if none.
*/ */
public List<Link> getOtherLinks() { public List<Link> getOtherLinks() {
return otherLinks == null ? (otherLinks = new ArrayList<Link>()) : otherLinks; if (otherLinks == null) {
otherLinks = new ArrayList<Link>();
}
return otherLinks;
} }
/** /**
@ -383,7 +419,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @since Atom 1.0 * @since Atom 1.0
*/ */
public Date getPublished() { public Date getPublished() {
return published == null ? null : new Date(published.getTime()); if (published == null) {
return null;
} else {
return new Date(published.getTime());
}
} }
/** /**
@ -521,7 +561,11 @@ public class Entry implements Cloneable, Serializable, Extendable {
* @since Atom 1.0 * @since Atom 1.0
*/ */
public Date getUpdated() { public Date getUpdated() {
return updated == null ? null : new Date(updated.getTime()); if (updated == null) {
return null;
} else {
return new Date(updated.getTime());
}
} }
/** /**

View file

@ -155,7 +155,10 @@ public class Feed extends WireFeed {
* list if none. * list if none.
*/ */
public List<Link> getAlternateLinks() { public List<Link> getAlternateLinks() {
return alternateLinks == null ? (alternateLinks = new ArrayList<Link>()) : alternateLinks; if (alternateLinks == null) {
alternateLinks = new ArrayList<Link>();
}
return alternateLinks;
} }
/** /**
@ -177,7 +180,10 @@ public class Feed extends WireFeed {
* ones), an empty list if none. * ones), an empty list if none.
*/ */
public List<Link> getOtherLinks() { public List<Link> getOtherLinks() {
return otherLinks == null ? (otherLinks = new ArrayList<Link>()) : otherLinks; if (otherLinks == null) {
otherLinks = new ArrayList<Link>();
}
return otherLinks;
} }
/** /**
@ -200,7 +206,10 @@ public class Feed extends WireFeed {
* *
*/ */
public List<Person> getAuthors() { public List<Person> getAuthors() {
return authors == null ? (authors = new ArrayList<Person>()) : authors; if (authors == null) {
authors = new ArrayList<Person>();
}
return authors;
} }
/** /**
@ -223,7 +232,10 @@ public class Feed extends WireFeed {
* *
*/ */
public List<Person> getContributors() { public List<Person> getContributors() {
return contributors == null ? (contributors = new ArrayList<Person>()) : contributors; if (contributors == null) {
contributors = new ArrayList<Person>();
}
return contributors;
} }
/** /**
@ -374,7 +386,10 @@ public class Feed extends WireFeed {
* *
*/ */
public List<Entry> getEntries() { public List<Entry> getEntries() {
return entries == null ? (entries = new ArrayList<Entry>()) : entries; if (entries == null) {
entries = new ArrayList<Entry>();
}
return entries;
} }
/** /**
@ -399,7 +414,10 @@ public class Feed extends WireFeed {
*/ */
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules; if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
} }
/** /**
@ -435,7 +453,10 @@ public class Feed extends WireFeed {
* @since Atom 1.0 * @since Atom 1.0
*/ */
public List<Category> getCategories() { public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories; if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
} }
/** /**

View file

@ -174,7 +174,11 @@ public class Link implements Cloneable, Serializable {
} }
public String getHrefResolved() { public String getHrefResolved() {
return hrefResolved != null ? hrefResolved : href; if (hrefResolved != null) {
return hrefResolved;
} else {
return href;
}
} }
/** /**

View file

@ -152,7 +152,11 @@ public class Person implements Cloneable, Serializable, Extendable {
} }
public String getUriResolved(final String resolveURI) { public String getUriResolved(final String resolveURI) {
return uriResolved != null ? uriResolved : uri; if (uriResolved != null) {
return uriResolved;
} else {
return uri;
}
} }
/** /**
@ -209,7 +213,10 @@ public class Person implements Cloneable, Serializable, Extendable {
*/ */
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules; if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
} }
/** /**

View file

@ -108,7 +108,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getTitles() { public List<String> getTitles() {
return title == null ? (title = new ArrayList<String>()) : title; if (title == null) {
title = new ArrayList<String>();
}
return title;
} }
/** /**
@ -133,7 +136,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getTitle() { public String getTitle() {
return title != null && title.size() > 0 ? (String) title.get(0) : null; if (title != null && title.size() > 0) {
return title.get(0);
} else {
return null;
}
} }
/** /**
@ -160,7 +167,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getCreators() { public List<String> getCreators() {
return creator == null ? (creator = new ArrayList<String>()) : creator; if (creator == null) {
creator = new ArrayList<String>();
}
return creator;
} }
/** /**
@ -185,7 +195,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getCreator() { public String getCreator() {
return creator != null && creator.size() > 0 ? (String) creator.get(0) : null; if (creator != null && creator.size() > 0) {
return creator.get(0);
} else {
return null;
}
} }
/** /**
@ -212,7 +226,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<DCSubject> getSubjects() { public List<DCSubject> getSubjects() {
return subject == null ? (subject = new ArrayList<DCSubject>()) : subject; if (subject == null) {
subject = new ArrayList<DCSubject>();
}
return subject;
} }
/** /**
@ -237,7 +254,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public DCSubject getSubject() { public DCSubject getSubject() {
return subject != null && subject.size() > 0 ? (DCSubject) subject.get(0) : null; if (subject != null && subject.size() > 0) {
return subject.get(0);
} else {
return null;
}
} }
/** /**
@ -264,7 +285,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getDescriptions() { public List<String> getDescriptions() {
return description == null ? (description = new ArrayList<String>()) : description; if (description == null) {
description = new ArrayList<String>();
}
return description;
} }
/** /**
@ -289,7 +313,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getDescription() { public String getDescription() {
return description != null && description.size() > 0 ? (String) description.get(0) : null; if (description != null && description.size() > 0) {
return description.get(0);
} else {
return null;
}
} }
/** /**
@ -317,7 +345,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getPublishers() { public List<String> getPublishers() {
return publisher == null ? (publisher = new ArrayList<String>()) : publisher; if (publisher == null) {
publisher = new ArrayList<String>();
}
return publisher;
} }
/** /**
@ -342,7 +373,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getPublisher() { public String getPublisher() {
return publisher != null && publisher.size() > 0 ? (String) publisher.get(0) : null; if (publisher != null && publisher.size() > 0) {
return publisher.get(0);
} else {
return null;
}
} }
/** /**
@ -370,7 +405,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getContributors() { public List<String> getContributors() {
return contributors == null ? (contributors = new ArrayList<String>()) : contributors; if (contributors == null) {
contributors = new ArrayList<String>();
}
return contributors;
} }
/** /**
@ -395,7 +433,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getContributor() { public String getContributor() {
return contributors != null && contributors.size() > 0 ? (String) contributors.get(0) : null; if (contributors != null && contributors.size() > 0) {
return contributors.get(0);
} else {
return null;
}
} }
/** /**
@ -423,7 +465,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<Date> getDates() { public List<Date> getDates() {
return date == null ? (date = new ArrayList<Date>()) : date; if (date == null) {
date = new ArrayList<Date>();
}
return date;
} }
/** /**
@ -448,7 +493,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public Date getDate() { public Date getDate() {
return date != null && date.size() > 0 ? (Date) date.get(0) : null; if (date != null && date.size() > 0) {
return date.get(0);
} else {
return null;
}
} }
/** /**
@ -475,7 +524,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getTypes() { public List<String> getTypes() {
return type == null ? (type = new ArrayList<String>()) : type; if (type == null) {
type = new ArrayList<String>();
}
return type;
} }
/** /**
@ -500,7 +552,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getType() { public String getType() {
return type != null && type.size() > 0 ? (String) type.get(0) : null; if (type != null && type.size() > 0) {
return type.get(0);
} else {
return null;
}
} }
/** /**
@ -527,7 +583,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getFormats() { public List<String> getFormats() {
return format == null ? (format = new ArrayList<String>()) : format; if (format == null) {
format = new ArrayList<String>();
}
return format;
} }
/** /**
@ -552,7 +611,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getFormat() { public String getFormat() {
return format != null && format.size() > 0 ? (String) format.get(0) : null; if (format != null && format.size() > 0) {
return format.get(0);
} else {
return null;
}
} }
/** /**
@ -579,7 +642,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getIdentifiers() { public List<String> getIdentifiers() {
return identifier == null ? (identifier = new ArrayList<String>()) : identifier; if (identifier == null) {
identifier = new ArrayList<String>();
}
return identifier;
} }
/** /**
@ -604,7 +670,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getIdentifier() { public String getIdentifier() {
return identifier != null && identifier.size() > 0 ? (String) identifier.get(0) : null; if (identifier != null && identifier.size() > 0) {
return identifier.get(0);
} else {
return null;
}
} }
/** /**
@ -632,7 +702,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getSources() { public List<String> getSources() {
return source == null ? (source = new ArrayList<String>()) : source; if (source == null) {
source = new ArrayList<String>();
}
return source;
} }
/** /**
@ -657,7 +730,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getSource() { public String getSource() {
return source != null && source.size() > 0 ? (String) source.get(0) : null; if (source != null && source.size() > 0) {
return source.get(0);
} else {
return null;
}
} }
/** /**
@ -684,7 +761,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getLanguages() { public List<String> getLanguages() {
return language == null ? (language = new ArrayList<String>()) : language; if (language == null) {
language = new ArrayList<String>();
}
return language;
} }
/** /**
@ -709,7 +789,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getLanguage() { public String getLanguage() {
return language != null && language.size() > 0 ? (String) language.get(0) : null; if (language != null && language.size() > 0) {
return language.get(0);
} else {
return null;
}
} }
/** /**
@ -737,7 +821,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getRelations() { public List<String> getRelations() {
return relation == null ? (relation = new ArrayList<String>()) : relation; if (relation == null) {
relation = new ArrayList<String>();
}
return relation;
} }
/** /**
@ -762,7 +849,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getRelation() { public String getRelation() {
return relation != null && relation.size() > 0 ? (String) relation.get(0) : null; if (relation != null && relation.size() > 0) {
return relation.get(0);
} else {
return null;
}
} }
/** /**
@ -790,7 +881,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getCoverages() { public List<String> getCoverages() {
return coverage == null ? (coverage = new ArrayList<String>()) : coverage; if (coverage == null) {
coverage = new ArrayList<String>();
}
return coverage;
} }
/** /**
@ -815,7 +909,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getCoverage() { public String getCoverage() {
return coverage != null && coverage.size() > 0 ? (String) coverage.get(0) : null; if (coverage != null && coverage.size() > 0) {
return coverage.get(0);
} else {
return null;
}
} }
/** /**
@ -843,7 +941,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public List<String> getRightsList() { public List<String> getRightsList() {
return rights == null ? (rights = new ArrayList<String>()) : rights; if (rights == null) {
rights = new ArrayList<String>();
}
return rights;
} }
/** /**
@ -868,7 +969,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule {
*/ */
@Override @Override
public String getRights() { public String getRights() {
return rights != null && rights.size() > 0 ? (String) rights.get(0) : null; if (rights != null && rights.size() > 0) {
return rights.get(0);
} else {
return null;
}
} }
/** /**

View file

@ -220,7 +220,10 @@ public class Channel extends WireFeed {
* *
*/ */
public List<Item> getItems() { public List<Item> getItems() {
return items == null ? (items = new ArrayList<Item>()) : items; if (items == null) {
items = new ArrayList<Item>();
}
return items;
} }
/** /**
@ -331,7 +334,11 @@ public class Channel extends WireFeed {
* *
*/ */
public Date getPubDate() { public Date getPubDate() {
return pubDate == null ? null : new Date(pubDate.getTime()); if (pubDate == null) {
return null;
} else {
return new Date(pubDate.getTime());
}
} }
/** /**
@ -353,7 +360,11 @@ public class Channel extends WireFeed {
* *
*/ */
public Date getLastBuildDate() { public Date getLastBuildDate() {
return lastBuildDate == null ? null : new Date(lastBuildDate.getTime()); if (lastBuildDate == null) {
return null;
} else {
return new Date(lastBuildDate.getTime());
}
} }
/** /**
@ -444,7 +455,11 @@ public class Channel extends WireFeed {
* *
*/ */
public List<Integer> getSkipHours() { public List<Integer> getSkipHours() {
return skipHours != null ? skipHours : new ArrayList<Integer>(); if (skipHours != null) {
return skipHours;
} else {
return new ArrayList<Integer>();
}
} }
/** /**
@ -481,7 +496,11 @@ public class Channel extends WireFeed {
* *
*/ */
public List<String> getSkipDays() { public List<String> getSkipDays() {
return skipDays != null ? skipDays : new ArrayList<String>(); if (skipDays != null) {
return skipDays;
} else {
return new ArrayList<String>();
}
} }
/** /**
@ -541,7 +560,10 @@ public class Channel extends WireFeed {
* *
*/ */
public List<Category> getCategories() { public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories; if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
} }
/** /**
@ -610,7 +632,10 @@ public class Channel extends WireFeed {
*/ */
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules; if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
} }
/** /**

View file

@ -270,7 +270,10 @@ public class Item implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Enclosure> getEnclosures() { public List<Enclosure> getEnclosures() {
return enclosures == null ? (enclosures = new ArrayList<Enclosure>()) : enclosures; if (enclosures == null) {
enclosures = new ArrayList<Enclosure>();
}
return enclosures;
} }
/** /**
@ -294,7 +297,10 @@ public class Item implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Category> getCategories() { public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories; if (categories == null) {
categories = new ArrayList<Category>();
}
return categories;
} }
/** /**
@ -385,7 +391,10 @@ public class Item implements Cloneable, Serializable, Extendable {
*/ */
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
return modules == null ? (modules = new ArrayList<Module>()) : modules; if (modules == null) {
modules = new ArrayList<Module>();
}
return modules;
} }
/** /**
@ -421,7 +430,11 @@ public class Item implements Cloneable, Serializable, Extendable {
* *
*/ */
public Date getPubDate() { public Date getPubDate() {
return pubDate == null ? null : new Date(pubDate.getTime()); if (pubDate == null) {
return null;
} else {
return new Date(pubDate.getTime());
}
} }
/** /**
@ -443,7 +456,11 @@ public class Item implements Cloneable, Serializable, Extendable {
* *
*/ */
public Date getExpirationDate() { public Date getExpirationDate() {
return expirationDate == null ? null : new Date(expirationDate.getTime()); if (expirationDate == null) {
return null;
} else {
return new Date(expirationDate.getTime());
}
} }
/** /**
@ -466,7 +483,10 @@ public class Item implements Cloneable, Serializable, Extendable {
* *
*/ */
public List<Element> getForeignMarkup() { public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup; if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
} }
/** /**

View file

@ -255,7 +255,11 @@ class SyndCategoryListFacade extends AbstractList<SyndCategory> {
final SyndCategoryImpl sCat = (SyndCategoryImpl) obj; final SyndCategoryImpl sCat = (SyndCategoryImpl) obj;
DCSubject subject = sCat != null ? sCat.getSubject() : null; DCSubject subject = sCat != null ? sCat.getSubject() : null;
subject = subjects.set(index, subject); subject = subjects.set(index, subject);
return subject != null ? new SyndCategoryImpl(subject) : null; if (subject != null) {
return new SyndCategoryImpl(subject);
} else {
return null;
}
} }
/** /**
@ -285,7 +289,11 @@ class SyndCategoryListFacade extends AbstractList<SyndCategory> {
@Override @Override
public SyndCategory remove(final int index) { public SyndCategory remove(final int index) {
final DCSubject subject = subjects.remove(index); final DCSubject subject = subjects.remove(index);
return subject != null ? new SyndCategoryImpl(subject) : null; if (subject != null) {
return new SyndCategoryImpl(subject);
} else {
return null;
}
} }
/** /**

View file

@ -326,7 +326,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/ */
@Override @Override
public List<SyndContent> getContents() { public List<SyndContent> getContents() {
return contents == null ? (contents = new ArrayList<SyndContent>()) : contents; if (contents == null) {
contents = new ArrayList<SyndContent>();
}
return contents;
} }
/** /**
@ -352,7 +355,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/ */
@Override @Override
public List<SyndEnclosure> getEnclosures() { public List<SyndEnclosure> getEnclosures() {
return enclosures == null ? (enclosures = new ArrayList<SyndEnclosure>()) : enclosures; if (enclosures == null) {
enclosures = new ArrayList<SyndEnclosure>();
}
return enclosures;
} }
/** /**
@ -522,7 +528,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/ */
@Override @Override
public List<SyndLink> getLinks() { public List<SyndLink> getLinks() {
return links == null ? (links = new ArrayList<SyndLink>()) : links; if (links == null) {
links = new ArrayList<SyndLink>();
}
return links;
} }
/** /**
@ -544,7 +553,11 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/ */
@Override @Override
public Date getUpdatedDate() { public Date getUpdatedDate() {
return updatedDate == null ? null : new Date(updatedDate.getTime()); if (updatedDate == null) {
return null;
} else {
return new Date(updatedDate.getTime());
}
} }
/** /**
@ -560,7 +573,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
@Override @Override
public List<SyndPerson> getAuthors() { public List<SyndPerson> getAuthors() {
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors; if (authors == null) {
authors = new ArrayList<SyndPerson>();
}
return authors;
} }
/* /*
@ -624,14 +640,12 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
@Override @Override
public List<SyndPerson> getContributors() { public List<SyndPerson> getContributors() {
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors; if (contributors == null) {
contributors = new ArrayList<SyndPerson>();
}
return contributors;
} }
/*
* (non-Javadoc)
* @see
* com.sun.syndication.feed.synd.SyndEntry#setContributors(java.util.List)
*/
@Override @Override
public void setContributors(final List<SyndPerson> contributors) { public void setContributors(final List<SyndPerson> contributors) {
this.contributors = contributors; this.contributors = contributors;
@ -657,7 +671,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry {
*/ */
@Override @Override
public List<Element> getForeignMarkup() { public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup; if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
} }
/** /**

View file

@ -678,7 +678,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
*/ */
@Override @Override
public List<SyndEntry> getEntries() { public List<SyndEntry> getEntries() {
return entries == null ? (entries = new ArrayList<SyndEntry>()) : entries; if (entries == null) {
entries = new ArrayList<SyndEntry>();
}
return entries;
} }
/** /**
@ -821,7 +824,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
*/ */
@Override @Override
public List<SyndLink> getLinks() { public List<SyndLink> getLinks() {
return links == null ? (links = new ArrayList<SyndLink>()) : links; if (links == null) {
links = new ArrayList<SyndLink>();
}
return links;
} }
/** /**
@ -837,7 +843,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
@Override @Override
public List<SyndPerson> getAuthors() { public List<SyndPerson> getAuthors() {
return authors == null ? (authors = new ArrayList<SyndPerson>()) : authors; if (authors == null) {
authors = new ArrayList<SyndPerson>();
}
return authors;
} }
@Override @Override
@ -877,7 +886,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
@Override @Override
public List<SyndPerson> getContributors() { public List<SyndPerson> getContributors() {
return contributors == null ? (contributors = new ArrayList<SyndPerson>()) : contributors; if (contributors == null) {
contributors = new ArrayList<SyndPerson>();
}
return contributors;
} }
@Override @Override
@ -894,7 +906,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
*/ */
@Override @Override
public List<Element> getForeignMarkup() { public List<Element> getForeignMarkup() {
return foreignMarkup == null ? (foreignMarkup = new ArrayList<Element>()) : foreignMarkup; if (foreignMarkup == null) {
foreignMarkup = new ArrayList<Element>();
}
return foreignMarkup;
} }
/** /**

View file

@ -61,7 +61,11 @@ public class ParsingFeedException extends FeedException {
* is not available. * is not available.
*/ */
public int getLineNumber() { public int getLineNumber() {
return getCause() instanceof JDOMParseException ? ((JDOMParseException) getCause()).getLineNumber() : -1; if (getCause() instanceof JDOMParseException) {
return ((JDOMParseException) getCause()).getLineNumber();
} else {
return -1;
}
} }
/** /**
@ -75,7 +79,11 @@ public class ParsingFeedException extends FeedException {
* information is not available. * information is not available.
*/ */
public int getColumnNumber() { public int getColumnNumber() {
return getCause() instanceof JDOMParseException ? ((JDOMParseException) getCause()).getColumnNumber() : -1; if (getCause() instanceof JDOMParseException) {
return ((JDOMParseException) getCause()).getColumnNumber();
} else {
return -1;
}
} }
} }

View file

@ -189,7 +189,11 @@ public class Atom03Parser extends BaseWireFeedParser {
} }
} }
} }
return links.size() > 0 ? links : null; if (links.size() > 0) {
return links;
} else {
return null;
}
} }
// List(Elements) -> List(Link) // List(Elements) -> List(Link)
@ -225,7 +229,11 @@ public class Atom03Parser extends BaseWireFeedParser {
for (int i = 0; i < ePersons.size(); i++) { for (int i = 0; i < ePersons.size(); i++) {
persons.add(parsePerson(ePersons.get(i))); persons.add(parsePerson(ePersons.get(i)));
} }
return persons.size() > 0 ? persons : null; if (persons.size() > 0) {
return persons;
} else {
return null;
}
} }
private Content parseContent(final Element e) { private Content parseContent(final Element e) {
@ -270,7 +278,11 @@ public class Atom03Parser extends BaseWireFeedParser {
for (int i = 0; i < eEntries.size(); i++) { for (int i = 0; i < eEntries.size(); i++) {
entries.add(parseEntry(eEntries.get(i))); entries.add(parseEntry(eEntries.get(i)));
} }
return entries.size() > 0 ? entries : null; if (entries.size() > 0) {
return entries;
} else {
return null;
}
} }
private Entry parseEntry(final Element eEntry) { private Entry parseEntry(final Element eEntry) {

View file

@ -256,7 +256,11 @@ public class Atom10Parser extends BaseWireFeedParser {
links.add(link); links.add(link);
} }
} }
return links.size() > 0 ? links : null; if (links.size() > 0) {
return links;
} else {
return null;
}
} }
private List<Link> parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) { private List<Link> parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {
@ -268,7 +272,11 @@ public class Atom10Parser extends BaseWireFeedParser {
links.add(link); links.add(link);
} }
} }
return links.size() > 0 ? links : null; if (links.size() > 0) {
return links;
} else {
return null;
}
} }
private Person parsePerson(final String baseURI, final Element ePerson) { private Person parsePerson(final String baseURI, final Element ePerson) {
@ -298,7 +306,11 @@ public class Atom10Parser extends BaseWireFeedParser {
for (int i = 0; i < ePersons.size(); i++) { for (int i = 0; i < ePersons.size(); i++) {
persons.add(parsePerson(baseURI, ePersons.get(i))); persons.add(parsePerson(baseURI, ePersons.get(i)));
} }
return persons.size() > 0 ? persons : null; if (persons.size() > 0) {
return persons;
} else {
return null;
}
} }
private Content parseContent(final Element e) { private Content parseContent(final Element e) {
@ -344,7 +356,11 @@ public class Atom10Parser extends BaseWireFeedParser {
for (int i = 0; i < eEntries.size(); i++) { for (int i = 0; i < eEntries.size(); i++) {
entries.add(this.parseEntry(feed, eEntries.get(i), baseURI)); entries.add(this.parseEntry(feed, eEntries.get(i), baseURI));
} }
return entries.size() > 0 ? entries : null; if (entries.size() > 0) {
return entries;
} else {
return null;
}
} }
protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI) { protected Entry parseEntry(final Feed feed, final Element eEntry, final String baseURI) {
@ -433,7 +449,11 @@ public class Atom10Parser extends BaseWireFeedParser {
final Element eCategory = eCategories.get(i); final Element eCategory = eCategories.get(i);
cats.add(parseCategory(baseURI, eCategory)); cats.add(parseCategory(baseURI, eCategory));
} }
return cats.size() > 0 ? cats : null; if (cats.size() > 0) {
return cats;
} else {
return null;
}
} }
private Category parseCategory(final String baseURI, final Element eCategory) { private Category parseCategory(final String baseURI, final Element eCategory) {

View file

@ -110,7 +110,11 @@ public abstract class BaseWireFeedParser implements WireFeedParser {
protected String getAttributeValue(final Element e, final String attributeName) { protected String getAttributeValue(final Element e, final String attributeName) {
final Attribute attr = getAttribute(e, attributeName); final Attribute attr = getAttribute(e, attributeName);
return attr != null ? attr.getValue() : null; if (attr != null) {
return attr.getValue();
} else {
return null;
}
} }
} }

View file

@ -147,8 +147,11 @@ public class DCModuleParser implements ModuleParser {
foundSomething = true; foundSomething = true;
dcm.setRightsList(parseElementList(eList)); dcm.setRightsList(parseElementList(eList));
} }
if (foundSomething) {
return foundSomething ? dcm : null; return dcm;
} else {
return null;
}
} }
/** /**

View file

@ -85,7 +85,11 @@ public class NumberParser {
*/ */
public static float parseFloat(final String str, final float def) { public static float parseFloat(final String str, final float def) {
final Float result = parseFloat(str); final Float result = parseFloat(str);
return result == null ? def : result.floatValue(); if (result == null) {
return def;
} else {
return result.floatValue();
}
} }
/** /**
@ -98,7 +102,11 @@ public class NumberParser {
*/ */
public static long parseLong(final String str, final long def) { public static long parseLong(final String str, final long def) {
final Long ret = parseLong(str); final Long ret = parseLong(str);
return null == ret ? def : ret.longValue(); if (null == ret) {
return def;
} else {
return ret.longValue();
}
} }
} }

View file

@ -197,7 +197,11 @@ public class RSS091UserlandParser extends RSS090Parser {
protected List<Element> getItems(final Element rssRoot) { protected List<Element> getItems(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
final List<Element> emptyList = Collections.emptyList(); final List<Element> emptyList = Collections.emptyList();
return eChannel != null ? eChannel.getChildren("item", getRSSNamespace()) : emptyList; if (eChannel != null) {
return eChannel.getChildren("item", getRSSNamespace());
} else {
return emptyList;
}
} }
/** /**
@ -206,7 +210,11 @@ public class RSS091UserlandParser extends RSS090Parser {
@Override @Override
protected Element getImage(final Element rssRoot) { protected Element getImage(final Element rssRoot) {
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
return eChannel != null ? eChannel.getChild("image", getRSSNamespace()) : null; if (eChannel != null) {
return eChannel.getChild("image", getRSSNamespace());
} else {
return null;
}
} }
/** /**
@ -223,7 +231,11 @@ public class RSS091UserlandParser extends RSS090Parser {
protected Element getTextInput(final Element rssRoot) { protected Element getTextInput(final Element rssRoot) {
final String elementName = getTextInputLabel(); final String elementName = getTextInputLabel();
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
return eChannel != null ? eChannel.getChild(elementName, getRSSNamespace()) : null; if (eChannel != null) {
return eChannel.getChild(elementName, getRSSNamespace());
} else {
return null;
}
} }
/** /**

View file

@ -84,7 +84,11 @@ public class RSS092Generator extends RSS091UserlandGenerator {
// Another one to thanks DW for // Another one to thanks DW for
protected int getNumberOfEnclosures(final List<Enclosure> enclosures) { protected int getNumberOfEnclosures(final List<Enclosure> enclosures) {
return enclosures.size() > 0 ? 1 : 0; if (enclosures.size() > 0) {
return 1;
} else {
return 0;
}
} }
@Override @Override

View file

@ -56,7 +56,11 @@ public class SyModuleParser implements ModuleParser {
foundSomething = true; foundSomething = true;
sm.setUpdateBase(DateParser.parseDate(e.getText())); sm.setUpdateBase(DateParser.parseDate(e.getText()));
} }
return foundSomething ? sm : null; if (foundSomething) {
return sm;
} else {
return null;
}
} }
} }