Refactoring code to use generics

This commit is contained in:
Patrick Gotthard 2014-04-12 23:22:05 +02:00
parent ac3fed65ce
commit abd3681044
15 changed files with 35 additions and 84 deletions

View file

@ -31,15 +31,9 @@ import com.sun.syndication.feed.CopyFrom;
*/
public class CustomTagsImpl implements CustomTags {
/**
*
*/
private static final long serialVersionUID = 1L;
private List<CustomTag> values;
/** Creates a new instance of CustomTagsImpl */
public CustomTagsImpl() {
}
private List<CustomTag> values;
@Override
public List<CustomTag> getValues() {
@ -66,7 +60,7 @@ public class CustomTagsImpl implements CustomTags {
}
@Override
public Class getInterface() {
public Class<CustomTags> getInterface() {
return CustomTags.class;
}

View file

@ -676,7 +676,7 @@ public class GoogleBaseImpl implements GoogleBase {
}
@Override
public Class getInterface() {
public Class<GoogleBase> getInterface() {
return GoogleBase.class;
}

View file

@ -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<CreativeCommons> 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();
}
}

View file

@ -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<ContentModuleImpl> 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<ContentModule> getInterface() {
return ContentModule.class;
}

View file

@ -78,7 +78,7 @@ public class FeedBurnerImpl implements FeedBurner {
}
@Override
public Class getInterface() {
public Class<FeedBurner> getInterface() {
return FeedBurner.class;
}

View file

@ -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<GeoRSSModule> getInterface() {
return GeoRSSModule.class;
}
}

View file

@ -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<? extends GeoRSSModule> beanClass, final java.lang.String uri) {
super(beanClass, uri);
}
@ -146,4 +144,5 @@ public abstract class GeoRSSModule extends ModuleImpl implements Cloneable {
}
throw new CloneNotSupportedException();
}
}

View file

@ -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<GeoRSSModule> getInterface() {
return GeoRSSModule.class;
}
}

View file

@ -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<GeoRSSModule> getInterface() {
return GeoRSSModule.class;
}

View file

@ -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<? extends AbstractITunesObject> getInterface() {
return getClass();
}

View file

@ -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<? extends MediaModule> clazz, final String uri) {
super(clazz, uri);
}
@Override
public Class getInterface() {
public Class<MediaModule> getInterface() {
return MediaModule.class;
}

View file

@ -147,7 +147,7 @@ public class PhotocastModuleImpl implements PhotocastModule {
}
@Override
public Class getInterface() {
public Class<PhotocastModule> getInterface() {
return PhotocastModule.class;
}

View file

@ -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<Slash> 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);
}
}

View file

@ -54,13 +54,14 @@ public class SimpleListExtensionImpl extends ModuleImpl implements SimpleListExt
/**
* Returns the interface the copyFrom works on.
* <p>
* 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.
* <p>
*
* @return the interface the copyFrom works on.
*/
@Override
public Class getInterface() {
public Class<SimpleListExtension> getInterface() {
return SimpleListExtension.class;
}
@ -100,8 +101,8 @@ public class SimpleListExtensionImpl extends ModuleImpl implements SimpleListExt
* <p>
* Any existing properties in this bean are lost.
* <p>
* 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.
* <p>
*
* @param obj the instance to copy properties from.

View file

@ -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);