From 1249adbaf91bcc6f1870b884ef9f1492d1046346 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Fri, 4 Oct 2013 10:06:06 +0200 Subject: [PATCH] Refactored ternary operators --- .../com/sun/syndication/feed/WireFeed.java | 10 +- .../sun/syndication/feed/atom/Category.java | 6 +- .../com/sun/syndication/feed/atom/Entry.java | 70 ++++++-- .../com/sun/syndication/feed/atom/Feed.java | 35 +++- .../com/sun/syndication/feed/atom/Link.java | 6 +- .../com/sun/syndication/feed/atom/Person.java | 11 +- .../syndication/feed/module/DCModuleImpl.java | 165 ++++++++++++++---- .../com/sun/syndication/feed/rss/Channel.java | 39 ++++- .../com/sun/syndication/feed/rss/Item.java | 32 +++- .../feed/synd/SyndCategoryImpl.java | 12 +- .../syndication/feed/synd/SyndEntryImpl.java | 41 +++-- .../syndication/feed/synd/SyndFeedImpl.java | 25 ++- .../syndication/io/ParsingFeedException.java | 12 +- .../sun/syndication/io/impl/Atom03Parser.java | 18 +- .../sun/syndication/io/impl/Atom10Parser.java | 30 +++- .../io/impl/BaseWireFeedParser.java | 6 +- .../syndication/io/impl/DCModuleParser.java | 7 +- .../sun/syndication/io/impl/NumberParser.java | 12 +- .../io/impl/RSS091UserlandParser.java | 18 +- .../syndication/io/impl/RSS092Generator.java | 6 +- .../syndication/io/impl/SyModuleParser.java | 6 +- 21 files changed, 459 insertions(+), 108 deletions(-) diff --git a/src/main/java/com/sun/syndication/feed/WireFeed.java b/src/main/java/com/sun/syndication/feed/WireFeed.java index 0a050e4..3f72e5d 100644 --- a/src/main/java/com/sun/syndication/feed/WireFeed.java +++ b/src/main/java/com/sun/syndication/feed/WireFeed.java @@ -195,7 +195,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -231,7 +234,10 @@ public abstract class WireFeed implements Cloneable, Serializable, Extendable { * */ public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Category.java b/src/main/java/com/sun/syndication/feed/atom/Category.java index 5cf0e73..7c1f81b 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Category.java +++ b/src/main/java/com/sun/syndication/feed/atom/Category.java @@ -146,7 +146,11 @@ public class Category implements Cloneable, Serializable { } public String getSchemeResolved() { - return schemeResolved != null ? schemeResolved : scheme; + if (schemeResolved != null) { + return schemeResolved; + } else { + return scheme; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Entry.java b/src/main/java/com/sun/syndication/feed/atom/Entry.java index d2ab156..ecfafde 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Entry.java +++ b/src/main/java/com/sun/syndication/feed/atom/Entry.java @@ -83,7 +83,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * list if none. */ public List getAlternateLinks() { - return alternateLinks == null ? (alternateLinks = new ArrayList()) : alternateLinks; + if (alternateLinks == null) { + alternateLinks = new ArrayList(); + } + return alternateLinks; } /** @@ -105,7 +108,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * */ public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /** @@ -127,7 +133,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -149,7 +158,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * if none. */ public List getContents() { - return contents == null ? (contents = new ArrayList()) : contents; + if (contents == null) { + contents = new ArrayList(); + } + return contents; } /** @@ -173,7 +185,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * */ public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** @@ -193,7 +208,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @return the entry created date, null if none. */ 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 getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** @@ -259,7 +281,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @return the entry issued date, null if none. */ 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, null if none. */ 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 public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -361,7 +394,10 @@ public class Entry implements Cloneable, Serializable, Extendable { * set, an empty list if none. */ public List getOtherLinks() { - return otherLinks == null ? (otherLinks = new ArrayList()) : otherLinks; + if (otherLinks == null) { + otherLinks = new ArrayList(); + } + return otherLinks; } /** @@ -383,7 +419,11 @@ public class Entry implements Cloneable, Serializable, Extendable { * @since Atom 1.0 */ 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 */ public Date getUpdated() { - return updated == null ? null : new Date(updated.getTime()); + if (updated == null) { + return null; + } else { + return new Date(updated.getTime()); + } } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Feed.java b/src/main/java/com/sun/syndication/feed/atom/Feed.java index a9b4d74..eabfc16 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Feed.java +++ b/src/main/java/com/sun/syndication/feed/atom/Feed.java @@ -155,7 +155,10 @@ public class Feed extends WireFeed { * list if none. */ public List getAlternateLinks() { - return alternateLinks == null ? (alternateLinks = new ArrayList()) : alternateLinks; + if (alternateLinks == null) { + alternateLinks = new ArrayList(); + } + return alternateLinks; } /** @@ -177,7 +180,10 @@ public class Feed extends WireFeed { * ones), an empty list if none. */ public List getOtherLinks() { - return otherLinks == null ? (otherLinks = new ArrayList()) : otherLinks; + if (otherLinks == null) { + otherLinks = new ArrayList(); + } + return otherLinks; } /** @@ -200,7 +206,10 @@ public class Feed extends WireFeed { * */ public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /** @@ -223,7 +232,10 @@ public class Feed extends WireFeed { * */ public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** @@ -374,7 +386,10 @@ public class Feed extends WireFeed { * */ public List getEntries() { - return entries == null ? (entries = new ArrayList()) : entries; + if (entries == null) { + entries = new ArrayList(); + } + return entries; } /** @@ -399,7 +414,10 @@ public class Feed extends WireFeed { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -435,7 +453,10 @@ public class Feed extends WireFeed { * @since Atom 1.0 */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Link.java b/src/main/java/com/sun/syndication/feed/atom/Link.java index 72fa493..c95175f 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Link.java +++ b/src/main/java/com/sun/syndication/feed/atom/Link.java @@ -174,7 +174,11 @@ public class Link implements Cloneable, Serializable { } public String getHrefResolved() { - return hrefResolved != null ? hrefResolved : href; + if (hrefResolved != null) { + return hrefResolved; + } else { + return href; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/atom/Person.java b/src/main/java/com/sun/syndication/feed/atom/Person.java index 76bbc71..dbece38 100644 --- a/src/main/java/com/sun/syndication/feed/atom/Person.java +++ b/src/main/java/com/sun/syndication/feed/atom/Person.java @@ -152,7 +152,11 @@ public class Person implements Cloneable, Serializable, Extendable { } 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 public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** diff --git a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java index d659de9..932e974 100644 --- a/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java +++ b/src/main/java/com/sun/syndication/feed/module/DCModuleImpl.java @@ -108,7 +108,10 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override public List getTitles() { - return title == null ? (title = new ArrayList()) : title; + if (title == null) { + title = new ArrayList(); + } + return title; } /** @@ -133,7 +136,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getCreators() { - return creator == null ? (creator = new ArrayList()) : creator; + if (creator == null) { + creator = new ArrayList(); + } + return creator; } /** @@ -185,7 +195,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getSubjects() { - return subject == null ? (subject = new ArrayList()) : subject; + if (subject == null) { + subject = new ArrayList(); + } + return subject; } /** @@ -237,7 +254,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getDescriptions() { - return description == null ? (description = new ArrayList()) : description; + if (description == null) { + description = new ArrayList(); + } + return description; } /** @@ -289,7 +313,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getPublishers() { - return publisher == null ? (publisher = new ArrayList()) : publisher; + if (publisher == null) { + publisher = new ArrayList(); + } + return publisher; } /** @@ -342,7 +373,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } /** @@ -395,7 +433,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getDates() { - return date == null ? (date = new ArrayList()) : date; + if (date == null) { + date = new ArrayList(); + } + return date; } /** @@ -448,7 +493,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getTypes() { - return type == null ? (type = new ArrayList()) : type; + if (type == null) { + type = new ArrayList(); + } + return type; } /** @@ -500,7 +552,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getFormats() { - return format == null ? (format = new ArrayList()) : format; + if (format == null) { + format = new ArrayList(); + } + return format; } /** @@ -552,7 +611,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getIdentifiers() { - return identifier == null ? (identifier = new ArrayList()) : identifier; + if (identifier == null) { + identifier = new ArrayList(); + } + return identifier; } /** @@ -604,7 +670,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getSources() { - return source == null ? (source = new ArrayList()) : source; + if (source == null) { + source = new ArrayList(); + } + return source; } /** @@ -657,7 +730,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getLanguages() { - return language == null ? (language = new ArrayList()) : language; + if (language == null) { + language = new ArrayList(); + } + return language; } /** @@ -709,7 +789,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getRelations() { - return relation == null ? (relation = new ArrayList()) : relation; + if (relation == null) { + relation = new ArrayList(); + } + return relation; } /** @@ -762,7 +849,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getCoverages() { - return coverage == null ? (coverage = new ArrayList()) : coverage; + if (coverage == null) { + coverage = new ArrayList(); + } + return coverage; } /** @@ -815,7 +909,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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 public List getRightsList() { - return rights == null ? (rights = new ArrayList()) : rights; + if (rights == null) { + rights = new ArrayList(); + } + return rights; } /** @@ -868,7 +969,11 @@ public class DCModuleImpl extends ModuleImpl implements DCModule { */ @Override 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; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/rss/Channel.java b/src/main/java/com/sun/syndication/feed/rss/Channel.java index 08b96ac..30ae6c1 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Channel.java +++ b/src/main/java/com/sun/syndication/feed/rss/Channel.java @@ -220,7 +220,10 @@ public class Channel extends WireFeed { * */ public List getItems() { - return items == null ? (items = new ArrayList()) : items; + if (items == null) { + items = new ArrayList(); + } + return items; } /** @@ -331,7 +334,11 @@ public class Channel extends WireFeed { * */ 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() { - 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 getSkipHours() { - return skipHours != null ? skipHours : new ArrayList(); + if (skipHours != null) { + return skipHours; + } else { + return new ArrayList(); + } } /** @@ -481,7 +496,11 @@ public class Channel extends WireFeed { * */ public List getSkipDays() { - return skipDays != null ? skipDays : new ArrayList(); + if (skipDays != null) { + return skipDays; + } else { + return new ArrayList(); + } } /** @@ -541,7 +560,10 @@ public class Channel extends WireFeed { * */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -610,7 +632,10 @@ public class Channel extends WireFeed { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** diff --git a/src/main/java/com/sun/syndication/feed/rss/Item.java b/src/main/java/com/sun/syndication/feed/rss/Item.java index c878441..e9f17c2 100644 --- a/src/main/java/com/sun/syndication/feed/rss/Item.java +++ b/src/main/java/com/sun/syndication/feed/rss/Item.java @@ -270,7 +270,10 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public List getEnclosures() { - return enclosures == null ? (enclosures = new ArrayList()) : enclosures; + if (enclosures == null) { + enclosures = new ArrayList(); + } + return enclosures; } /** @@ -294,7 +297,10 @@ public class Item implements Cloneable, Serializable, Extendable { * */ public List getCategories() { - return categories == null ? (categories = new ArrayList()) : categories; + if (categories == null) { + categories = new ArrayList(); + } + return categories; } /** @@ -385,7 +391,10 @@ public class Item implements Cloneable, Serializable, Extendable { */ @Override public List getModules() { - return modules == null ? (modules = new ArrayList()) : modules; + if (modules == null) { + modules = new ArrayList(); + } + return modules; } /** @@ -421,7 +430,11 @@ public class Item implements Cloneable, Serializable, Extendable { * */ 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() { - 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 getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java index 0bb5192..3951f31 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndCategoryImpl.java @@ -255,7 +255,11 @@ class SyndCategoryListFacade extends AbstractList { final SyndCategoryImpl sCat = (SyndCategoryImpl) obj; DCSubject subject = sCat != null ? sCat.getSubject() : null; 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 { @Override public SyndCategory remove(final int index) { final DCSubject subject = subjects.remove(index); - return subject != null ? new SyndCategoryImpl(subject) : null; + if (subject != null) { + return new SyndCategoryImpl(subject); + } else { + return null; + } } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java index 0b91e87..c9d6112 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndEntryImpl.java @@ -326,7 +326,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getContents() { - return contents == null ? (contents = new ArrayList()) : contents; + if (contents == null) { + contents = new ArrayList(); + } + return contents; } /** @@ -352,7 +355,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getEnclosures() { - return enclosures == null ? (enclosures = new ArrayList()) : enclosures; + if (enclosures == null) { + enclosures = new ArrayList(); + } + return enclosures; } /** @@ -522,7 +528,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getLinks() { - return links == null ? (links = new ArrayList()) : links; + if (links == null) { + links = new ArrayList(); + } + return links; } /** @@ -544,7 +553,11 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override 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 public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } /* @@ -624,14 +640,12 @@ public class SyndEntryImpl implements Serializable, SyndEntry { @Override public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } - /* - * (non-Javadoc) - * @see - * com.sun.syndication.feed.synd.SyndEntry#setContributors(java.util.List) - */ @Override public void setContributors(final List contributors) { this.contributors = contributors; @@ -657,7 +671,10 @@ public class SyndEntryImpl implements Serializable, SyndEntry { */ @Override public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java index 335f86e..8016aab 100644 --- a/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java +++ b/src/main/java/com/sun/syndication/feed/synd/SyndFeedImpl.java @@ -678,7 +678,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { */ @Override public List getEntries() { - return entries == null ? (entries = new ArrayList()) : entries; + if (entries == null) { + entries = new ArrayList(); + } + return entries; } /** @@ -821,7 +824,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { */ @Override public List getLinks() { - return links == null ? (links = new ArrayList()) : links; + if (links == null) { + links = new ArrayList(); + } + return links; } /** @@ -837,7 +843,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { @Override public List getAuthors() { - return authors == null ? (authors = new ArrayList()) : authors; + if (authors == null) { + authors = new ArrayList(); + } + return authors; } @Override @@ -877,7 +886,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { @Override public List getContributors() { - return contributors == null ? (contributors = new ArrayList()) : contributors; + if (contributors == null) { + contributors = new ArrayList(); + } + return contributors; } @Override @@ -894,7 +906,10 @@ public class SyndFeedImpl implements Serializable, SyndFeed { */ @Override public List getForeignMarkup() { - return foreignMarkup == null ? (foreignMarkup = new ArrayList()) : foreignMarkup; + if (foreignMarkup == null) { + foreignMarkup = new ArrayList(); + } + return foreignMarkup; } /** diff --git a/src/main/java/com/sun/syndication/io/ParsingFeedException.java b/src/main/java/com/sun/syndication/io/ParsingFeedException.java index d4acf0f..4ca164b 100644 --- a/src/main/java/com/sun/syndication/io/ParsingFeedException.java +++ b/src/main/java/com/sun/syndication/io/ParsingFeedException.java @@ -61,7 +61,11 @@ public class ParsingFeedException extends FeedException { * is not available. */ 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. */ public int getColumnNumber() { - return getCause() instanceof JDOMParseException ? ((JDOMParseException) getCause()).getColumnNumber() : -1; + if (getCause() instanceof JDOMParseException) { + return ((JDOMParseException) getCause()).getColumnNumber(); + } else { + return -1; + } } } diff --git a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java index 6a3cb0a..3557f76 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom03Parser.java @@ -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) @@ -225,7 +229,11 @@ public class Atom03Parser extends BaseWireFeedParser { for (int i = 0; i < ePersons.size(); 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) { @@ -270,7 +278,11 @@ public class Atom03Parser extends BaseWireFeedParser { for (int i = 0; i < eEntries.size(); 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) { diff --git a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java index 4f68894..45931e1 100644 --- a/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java +++ b/src/main/java/com/sun/syndication/io/impl/Atom10Parser.java @@ -256,7 +256,11 @@ public class Atom10Parser extends BaseWireFeedParser { links.add(link); } } - return links.size() > 0 ? links : null; + if (links.size() > 0) { + return links; + } else { + return null; + } } private List parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List eLinks) { @@ -268,7 +272,11 @@ public class Atom10Parser extends BaseWireFeedParser { 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) { @@ -298,7 +306,11 @@ public class Atom10Parser extends BaseWireFeedParser { for (int i = 0; i < ePersons.size(); 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) { @@ -344,7 +356,11 @@ public class Atom10Parser extends BaseWireFeedParser { for (int i = 0; i < eEntries.size(); i++) { 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) { @@ -433,7 +449,11 @@ public class Atom10Parser extends BaseWireFeedParser { final Element eCategory = eCategories.get(i); 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) { diff --git a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java index a00e190..036ac86 100644 --- a/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java +++ b/src/main/java/com/sun/syndication/io/impl/BaseWireFeedParser.java @@ -110,7 +110,11 @@ public abstract class BaseWireFeedParser implements WireFeedParser { protected String getAttributeValue(final Element e, final String attributeName) { final Attribute attr = getAttribute(e, attributeName); - return attr != null ? attr.getValue() : null; + if (attr != null) { + return attr.getValue(); + } else { + return null; + } } } diff --git a/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java b/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java index 8d1997c..40d03f4 100644 --- a/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java +++ b/src/main/java/com/sun/syndication/io/impl/DCModuleParser.java @@ -147,8 +147,11 @@ public class DCModuleParser implements ModuleParser { foundSomething = true; dcm.setRightsList(parseElementList(eList)); } - - return foundSomething ? dcm : null; + if (foundSomething) { + return dcm; + } else { + return null; + } } /** diff --git a/src/main/java/com/sun/syndication/io/impl/NumberParser.java b/src/main/java/com/sun/syndication/io/impl/NumberParser.java index ec955a1..234a82d 100644 --- a/src/main/java/com/sun/syndication/io/impl/NumberParser.java +++ b/src/main/java/com/sun/syndication/io/impl/NumberParser.java @@ -85,7 +85,11 @@ public class NumberParser { */ public static float parseFloat(final String str, final float def) { 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) { final Long ret = parseLong(str); - return null == ret ? def : ret.longValue(); + if (null == ret) { + return def; + } else { + return ret.longValue(); + } } } diff --git a/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java b/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java index 4a7d7fd..eac91c2 100644 --- a/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java +++ b/src/main/java/com/sun/syndication/io/impl/RSS091UserlandParser.java @@ -197,7 +197,11 @@ public class RSS091UserlandParser extends RSS090Parser { protected List getItems(final Element rssRoot) { final Element eChannel = rssRoot.getChild("channel", getRSSNamespace()); final List 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 protected Element getImage(final Element rssRoot) { 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) { final String elementName = getTextInputLabel(); 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; + } } /** diff --git a/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java b/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java index 14633e5..12debc3 100644 --- a/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java +++ b/src/main/java/com/sun/syndication/io/impl/RSS092Generator.java @@ -84,7 +84,11 @@ public class RSS092Generator extends RSS091UserlandGenerator { // Another one to thanks DW for protected int getNumberOfEnclosures(final List enclosures) { - return enclosures.size() > 0 ? 1 : 0; + if (enclosures.size() > 0) { + return 1; + } else { + return 0; + } } @Override diff --git a/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java b/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java index 012b5b0..a44a2c8 100644 --- a/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java +++ b/src/main/java/com/sun/syndication/io/impl/SyModuleParser.java @@ -56,7 +56,11 @@ public class SyModuleParser implements ModuleParser { foundSomething = true; sm.setUpdateBase(DateParser.parseDate(e.getText())); } - return foundSomething ? sm : null; + if (foundSomething) { + return sm; + } else { + return null; + } } }