Refactored some code

This commit is contained in:
Patrick Gotthard 2013-11-15 23:59:02 +01:00
parent f9181800cd
commit 53b5e3bec3

View file

@ -19,12 +19,17 @@ package com.sun.syndication.feed.module.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.syndication.feed.module.Module; import com.sun.syndication.feed.module.Module;
/** /**
*/ */
public class ModuleUtils { public class ModuleUtils {
private static final Logger LOG = LoggerFactory.getLogger(ModuleUtils.class);
public static List<Module> cloneModules(final List<Module> modules) { public static List<Module> cloneModules(final List<Module> modules) {
List<Module> cModules = null; List<Module> cModules = null;
if (modules != null) { if (modules != null) {
@ -33,8 +38,10 @@ public class ModuleUtils {
try { try {
final Module c = (Module) module.clone(); final Module c = (Module) module.clone();
cModules.add(c); cModules.add(c);
} catch (final Exception ex) { } catch (final Exception e) {
throw new RuntimeException("Cloning modules " + module.getUri(), ex); final String moduleUri = module.getUri();
LOG.error("Error while cloning module " + moduleUri, e);
throw new RuntimeException("Cloning modules " + moduleUri, e);
} }
} }
} }
@ -51,14 +58,16 @@ public class ModuleUtils {
* @return * @return
*/ */
public static Module getModule(final List<Module> modules, final String uri) { public static Module getModule(final List<Module> modules, final String uri) {
Module module = null; Module searchedModule = null;
for (int i = 0; modules != null && i < modules.size(); i++) { if (modules != null) {
module = modules.get(i); for (final Module module : modules) {
if (module.getUri().equals(uri)) { if (module.getUri().equals(uri)) {
return module; searchedModule = module;
break;
} }
} }
return null; }
return searchedModule;
} }
} }