de.mrapp.parser.feed.common.util.CollectionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javafeedparsercommon Show documentation
Show all versions of javafeedparsercommon Show documentation
Contains common classes of projects, which allow to parse feeds
The newest version!
/*
* JavaFeedParserCommon Copyright 2013-2014 Michael Rapp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package de.mrapp.parser.feed.common.util;
import java.util.Collection;
import java.util.LinkedList;
import de.mrapp.parser.feed.common.model.Entity;
/**
* An utility class, which offers static methods, which allow to handle
* instances of the type {@link Collection}.
*
* @author Michael Rapp
*
* @since 1.0.0
*/
public final class CollectionUtil {
/**
* Creates a new utility class, which offers static methods, which allow to
* handle instances of the type {@link Collection}.
*/
private CollectionUtil() {
}
/**
* Creates and returns a deep copy of a specific collection, respectively
* its entries. The collection's entries must implement the interface
* {@link Entity}.
*
* @param
* The type of the collection's entries
* @param collection
* The collection, which should be cloned, as an instance of the
* type {@link Collection}
* @return A collection, which contains the cloned entries of the given
* collection, as an instance of the type {@link Collection}
* @throws CloneNotSupportedException
* The exception, which is thrown, if at least one of the
* collection's entries does not support cloning
*/
@SuppressWarnings("unchecked")
public static Collection cloneCollection(
final Collection collection)
throws CloneNotSupportedException {
Collection clonedCollection = new LinkedList();
for (EntryType entry : collection) {
clonedCollection.add((EntryType) entry.clone());
}
return clonedCollection;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy