From abd3681044ff3bab2e3c70187bd951c7764f2dc1 Mon Sep 17 00:00:00 2001 From: Patrick Gotthard Date: Sat, 12 Apr 2014 23:22:05 +0200 Subject: [PATCH] Refactoring code to use generics --- .../rometools/feed/module/base/CustomTagsImpl.java | 10 ++-------- .../rometools/feed/module/base/GoogleBaseImpl.java | 2 +- .../feed/module/cc/CreativeCommonsImpl.java | 8 +++----- .../feed/module/content/ContentModuleImpl.java | 4 ++-- .../feed/module/feedburner/FeedBurnerImpl.java | 2 +- .../feed/module/georss/GMLModuleImpl.java | 13 ++++--------- .../rometools/feed/module/georss/GeoRSSModule.java | 7 +++---- .../feed/module/georss/SimpleModuleImpl.java | 14 +++++--------- .../feed/module/georss/W3CGeoModuleImpl.java | 12 +++--------- .../feed/module/itunes/AbstractITunesObject.java | 12 +----------- .../feed/module/mediarss/MediaModuleImpl.java | 4 ++-- .../feed/module/photocast/PhotocastModuleImpl.java | 2 +- .../org/rometools/feed/module/slash/SlashImpl.java | 13 ++----------- .../feed/module/sle/SimpleListExtensionImpl.java | 9 +++++---- .../module/base/io/GoogleBaseGeneratorTest.java | 7 ------- 15 files changed, 35 insertions(+), 84 deletions(-) diff --git a/src/main/java/org/rometools/feed/module/base/CustomTagsImpl.java b/src/main/java/org/rometools/feed/module/base/CustomTagsImpl.java index c5d20c7..4c87f56 100644 --- a/src/main/java/org/rometools/feed/module/base/CustomTagsImpl.java +++ b/src/main/java/org/rometools/feed/module/base/CustomTagsImpl.java @@ -31,15 +31,9 @@ import com.sun.syndication.feed.CopyFrom; */ public class CustomTagsImpl implements CustomTags { - /** - * - */ private static final long serialVersionUID = 1L; - private List values; - /** Creates a new instance of CustomTagsImpl */ - public CustomTagsImpl() { - } + private List values; @Override public List getValues() { @@ -66,7 +60,7 @@ public class CustomTagsImpl implements CustomTags { } @Override - public Class getInterface() { + public Class getInterface() { return CustomTags.class; } diff --git a/src/main/java/org/rometools/feed/module/base/GoogleBaseImpl.java b/src/main/java/org/rometools/feed/module/base/GoogleBaseImpl.java index 12cd7f9..5fc0dfd 100644 --- a/src/main/java/org/rometools/feed/module/base/GoogleBaseImpl.java +++ b/src/main/java/org/rometools/feed/module/base/GoogleBaseImpl.java @@ -676,7 +676,7 @@ public class GoogleBaseImpl implements GoogleBase { } @Override - public Class getInterface() { + public Class getInterface() { return GoogleBase.class; } diff --git a/src/main/java/org/rometools/feed/module/cc/CreativeCommonsImpl.java b/src/main/java/org/rometools/feed/module/cc/CreativeCommonsImpl.java index 3a39696..aae52bd 100644 --- a/src/main/java/org/rometools/feed/module/cc/CreativeCommonsImpl.java +++ b/src/main/java/org/rometools/feed/module/cc/CreativeCommonsImpl.java @@ -54,10 +54,8 @@ import com.sun.syndication.feed.impl.ToStringBean; */ public class CreativeCommonsImpl implements CreativeCommons { - /** - * - */ private static final long serialVersionUID = 1L; + public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; public static final String RSS2_URI = "http://backend.userland.com/creativeCommonsRssModule"; public static final String RSS1_URI = "http://web.resource.org/cc/"; @@ -90,7 +88,7 @@ public class CreativeCommonsImpl implements CreativeCommons { } @Override - public Class getInterface() { + public Class getInterface() { return CreativeCommons.class; } @@ -132,8 +130,8 @@ public class CreativeCommonsImpl implements CreativeCommons { @Override public String toString() { - final ToStringBean tsb = new ToStringBean(CreativeCommonsImpl.class, this); return tsb.toString(); } + } diff --git a/src/main/java/org/rometools/feed/module/content/ContentModuleImpl.java b/src/main/java/org/rometools/feed/module/content/ContentModuleImpl.java index 09f6bdd..d3edfbc 100644 --- a/src/main/java/org/rometools/feed/module/content/ContentModuleImpl.java +++ b/src/main/java/org/rometools/feed/module/content/ContentModuleImpl.java @@ -65,7 +65,7 @@ public class ContentModuleImpl extends ModuleImpl implements ContentModule { super(ContentModuleImpl.class, URI); } - protected ContentModuleImpl(final Class beanClass, final java.lang.String uri) { + protected ContentModuleImpl(final Class beanClass, final java.lang.String uri) { super(beanClass, uri); } @@ -89,7 +89,7 @@ public class ContentModuleImpl extends ModuleImpl implements ContentModule { } @Override - public Class getInterface() { + public Class getInterface() { return ContentModule.class; } diff --git a/src/main/java/org/rometools/feed/module/feedburner/FeedBurnerImpl.java b/src/main/java/org/rometools/feed/module/feedburner/FeedBurnerImpl.java index 1ec3d38..5d274a4 100644 --- a/src/main/java/org/rometools/feed/module/feedburner/FeedBurnerImpl.java +++ b/src/main/java/org/rometools/feed/module/feedburner/FeedBurnerImpl.java @@ -78,7 +78,7 @@ public class FeedBurnerImpl implements FeedBurner { } @Override - public Class getInterface() { + public Class getInterface() { return FeedBurner.class; } diff --git a/src/main/java/org/rometools/feed/module/georss/GMLModuleImpl.java b/src/main/java/org/rometools/feed/module/georss/GMLModuleImpl.java index a26dd90..edb41f6 100644 --- a/src/main/java/org/rometools/feed/module/georss/GMLModuleImpl.java +++ b/src/main/java/org/rometools/feed/module/georss/GMLModuleImpl.java @@ -17,7 +17,8 @@ package org.rometools.feed.module.georss; /** - * GMLModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the gml GeoRSS format. + * GMLModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the gml GeoRSS + * format. * * @author Marc Wick * @version $Id: GMLModuleImpl.java,v 1.1 2007/04/18 09:59:29 marcwick Exp $ @@ -25,21 +26,15 @@ package org.rometools.feed.module.georss; */ public class GMLModuleImpl extends GeoRSSModule { - /** - * - */ private static final long serialVersionUID = 1L; public GMLModuleImpl() { super(GeoRSSModule.class, GeoRSSModule.GEORSS_GML_URI); } - /* - * (non-Javadoc) - * @see com.sun.syndication.feed.CopyFrom#getInterface() - */ @Override - public Class getInterface() { + public Class getInterface() { return GeoRSSModule.class; } + } diff --git a/src/main/java/org/rometools/feed/module/georss/GeoRSSModule.java b/src/main/java/org/rometools/feed/module/georss/GeoRSSModule.java index 2996649..8337271 100644 --- a/src/main/java/org/rometools/feed/module/georss/GeoRSSModule.java +++ b/src/main/java/org/rometools/feed/module/georss/GeoRSSModule.java @@ -32,9 +32,7 @@ import com.sun.syndication.feed.module.ModuleImpl; * @version $Id: GeoRSSModule.java,v 1.8 2007/06/06 09:47:32 marcwick Exp $ */ public abstract class GeoRSSModule extends ModuleImpl implements Cloneable { - /** - * - */ + private static final long serialVersionUID = 1L; protected AbstractGeometry geometry; @@ -73,7 +71,7 @@ public abstract class GeoRSSModule extends ModuleImpl implements Cloneable { */ public static final Namespace GML_NS = Namespace.getNamespace("gml", GeoRSSModule.GEORSS_GML_URI); - protected GeoRSSModule(final Class beanClass, final java.lang.String uri) { + protected GeoRSSModule(final Class beanClass, final java.lang.String uri) { super(beanClass, uri); } @@ -146,4 +144,5 @@ public abstract class GeoRSSModule extends ModuleImpl implements Cloneable { } throw new CloneNotSupportedException(); } + } diff --git a/src/main/java/org/rometools/feed/module/georss/SimpleModuleImpl.java b/src/main/java/org/rometools/feed/module/georss/SimpleModuleImpl.java index 8cfef68..f6dce2b 100644 --- a/src/main/java/org/rometools/feed/module/georss/SimpleModuleImpl.java +++ b/src/main/java/org/rometools/feed/module/georss/SimpleModuleImpl.java @@ -17,28 +17,24 @@ package org.rometools.feed.module.georss; /** - * SimpleModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the GeoRSS Simple format. + * SimpleModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the GeoRSS + * Simple format. * * @author Marc Wick * @version $Id: SimpleModuleImpl.java,v 1.4 2007/04/18 09:59:29 marcwick Exp $ * */ public class SimpleModuleImpl extends GeoRSSModule { - /** - * - */ + private static final long serialVersionUID = 1L; public SimpleModuleImpl() { super(GeoRSSModule.class, GeoRSSModule.GEORSS_GEORSS_URI); } - /* - * (non-Javadoc) - * @see com.sun.syndication.feed.CopyFrom#getInterface() - */ @Override - public Class getInterface() { + public Class getInterface() { return GeoRSSModule.class; } + } diff --git a/src/main/java/org/rometools/feed/module/georss/W3CGeoModuleImpl.java b/src/main/java/org/rometools/feed/module/georss/W3CGeoModuleImpl.java index 9f8464f..8a9460a 100644 --- a/src/main/java/org/rometools/feed/module/georss/W3CGeoModuleImpl.java +++ b/src/main/java/org/rometools/feed/module/georss/W3CGeoModuleImpl.java @@ -17,7 +17,8 @@ package org.rometools.feed.module.georss; /** - * W3CGeoModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the W3C geo format. + * W3CGeoModuleImpl is the implementation of the {@link GeoRSSModule} Interface for the W3C geo + * format. * * @author Marc Wick * @version $Id: W3CGeoModuleImpl.java,v 1.2 2007/04/18 09:59:29 marcwick Exp $ @@ -25,21 +26,14 @@ package org.rometools.feed.module.georss; */ public class W3CGeoModuleImpl extends GeoRSSModule { - /** - * - */ private static final long serialVersionUID = 1L; public W3CGeoModuleImpl() { super(GeoRSSModule.class, GeoRSSModule.GEORSS_W3CGEO_URI); } - /* - * (non-Javadoc) - * @see com.sun.syndication.feed.CopyFrom#getInterface() - */ @Override - public Class getInterface() { + public Class getInterface() { return GeoRSSModule.class; } diff --git a/src/main/java/org/rometools/feed/module/itunes/AbstractITunesObject.java b/src/main/java/org/rometools/feed/module/itunes/AbstractITunesObject.java index 56bbe7a..b66e5e9 100644 --- a/src/main/java/org/rometools/feed/module/itunes/AbstractITunesObject.java +++ b/src/main/java/org/rometools/feed/module/itunes/AbstractITunesObject.java @@ -40,8 +40,6 @@ */ package org.rometools.feed.module.itunes; -import com.sun.syndication.feed.CopyFrom; - /** * This is an abstract object that implements the attributes common across Feeds or Items in an * iTunes compatible RSS feed. @@ -80,21 +78,13 @@ public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneabl private String subtitle; private String summary; - /** - * Defined by the ROME module API - * - * @param obj Object to copy from - */ - @Override - public abstract void copyFrom(CopyFrom obj); - /** * Defined by the ROME API * * @return Class of the Interface for this module. */ @Override - public Class getInterface() { + public Class getInterface() { return getClass(); } diff --git a/src/main/java/org/rometools/feed/module/mediarss/MediaModuleImpl.java b/src/main/java/org/rometools/feed/module/mediarss/MediaModuleImpl.java index 5b5061f..382845f 100644 --- a/src/main/java/org/rometools/feed/module/mediarss/MediaModuleImpl.java +++ b/src/main/java/org/rometools/feed/module/mediarss/MediaModuleImpl.java @@ -53,12 +53,12 @@ public class MediaModuleImpl extends ModuleImpl implements MediaModule, Serializ * @param clazz * @param uri */ - public MediaModuleImpl(final Class clazz, final String uri) { + public MediaModuleImpl(final Class clazz, final String uri) { super(clazz, uri); } @Override - public Class getInterface() { + public Class getInterface() { return MediaModule.class; } diff --git a/src/main/java/org/rometools/feed/module/photocast/PhotocastModuleImpl.java b/src/main/java/org/rometools/feed/module/photocast/PhotocastModuleImpl.java index c319c0b..b45c495 100644 --- a/src/main/java/org/rometools/feed/module/photocast/PhotocastModuleImpl.java +++ b/src/main/java/org/rometools/feed/module/photocast/PhotocastModuleImpl.java @@ -147,7 +147,7 @@ public class PhotocastModuleImpl implements PhotocastModule { } @Override - public Class getInterface() { + public Class getInterface() { return PhotocastModule.class; } diff --git a/src/main/java/org/rometools/feed/module/slash/SlashImpl.java b/src/main/java/org/rometools/feed/module/slash/SlashImpl.java index 81c85c7..b80e95a 100644 --- a/src/main/java/org/rometools/feed/module/slash/SlashImpl.java +++ b/src/main/java/org/rometools/feed/module/slash/SlashImpl.java @@ -50,23 +50,13 @@ import com.sun.syndication.feed.impl.EqualsBean; */ public class SlashImpl implements Slash { - /** - * - */ private static final long serialVersionUID = 1L; private String section; - private String department; - private Integer comments; - private Integer[] hitParade; - /** Creates a new instance of SlashImpl */ - public SlashImpl() { - } - @Override public String getSection() { return section; @@ -142,7 +132,7 @@ public class SlashImpl implements Slash { } @Override - public Class getInterface() { + public Class getInterface() { return Slash.class; } @@ -151,4 +141,5 @@ public class SlashImpl implements Slash { final EqualsBean eBean = new EqualsBean(this.getClass(), this); return eBean.beanEquals(obj); } + } diff --git a/src/main/java/org/rometools/feed/module/sle/SimpleListExtensionImpl.java b/src/main/java/org/rometools/feed/module/sle/SimpleListExtensionImpl.java index 1c2dd61..301739c 100644 --- a/src/main/java/org/rometools/feed/module/sle/SimpleListExtensionImpl.java +++ b/src/main/java/org/rometools/feed/module/sle/SimpleListExtensionImpl.java @@ -54,13 +54,14 @@ public class SimpleListExtensionImpl extends ModuleImpl implements SimpleListExt /** * Returns the interface the copyFrom works on. *

- * This is useful when dealing with properties that may have multiple implementations. For example, Module. + * This is useful when dealing with properties that may have multiple implementations. For + * example, Module. *

* * @return the interface the copyFrom works on. */ @Override - public Class getInterface() { + public Class getInterface() { return SimpleListExtension.class; } @@ -100,8 +101,8 @@ public class SimpleListExtensionImpl extends ModuleImpl implements SimpleListExt *

* Any existing properties in this bean are lost. *

- * This method is useful for moving from one implementation of a bean interface to another. For example from the default SyndFeed bean implementation to a - * Hibernate ready implementation. + * This method is useful for moving from one implementation of a bean interface to another. For + * example from the default SyndFeed bean implementation to a Hibernate ready implementation. *

* * @param obj the instance to copy properties from. diff --git a/src/test/java/org/rometools/feed/module/base/io/GoogleBaseGeneratorTest.java b/src/test/java/org/rometools/feed/module/base/io/GoogleBaseGeneratorTest.java index ca9510f..8862f00 100644 --- a/src/test/java/org/rometools/feed/module/base/io/GoogleBaseGeneratorTest.java +++ b/src/test/java/org/rometools/feed/module/base/io/GoogleBaseGeneratorTest.java @@ -104,13 +104,6 @@ public class GoogleBaseGeneratorTest extends AbstractTestCase { product.setCondition("New"); product.setDeliveryNotes("Insight"); - // FIXME - final List modules = new ArrayList(); - modules.add(vehicle); - modules.add(product); - - entry.setModules(modules); - entries.add(entry); feed.setEntries(entries);