diff options
Diffstat (limited to 'catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java')
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java index 15bef3b23b..1a6017c582 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.dao.utils; import java.util.ArrayList; @@ -30,6 +29,7 @@ import java.util.Map.Entry; import java.util.Set; public final class CollectionUtils { + private CollectionUtils() { } @@ -38,18 +38,14 @@ public final class CollectionUtils { } /** - * Add the content of the 'source' Set to the 'target' set and return the - * union set. + * Add the content of the 'source' Set to the 'target' set and return the union set. * <p> - * If 'source' is null then a new set is created and returned. If 'target' - * is null then no content is added to the 'source' Set or newly created + * If 'source' is null then a new set is created and returned. If 'target' is null then no content is added to the 'source' Set or newly created * set. * * @param source The Set to merge in the target Set. - * @param target The Set in which the source set will be merged (through - * addAll). - * @return The target Set with addition of source Set elements, or a new Set - * (including content of source set) if target was null. + * @param target The Set in which the source set will be merged (through addAll). + * @return The target Set with addition of source Set elements, or a new Set (including content of source set) if target was null. */ public static <T> Set<T> merge(Set<T> source, Set<T> target) { Set<T> merged = new HashSet<>(); @@ -64,28 +60,22 @@ public final class CollectionUtils { /** * <p> - * Add the content of the 'source' Map to the 'target' set and return the - * union Map. + * Add the content of the 'source' Map to the 'target' set and return the union Map. * </p> * <p> - * If 'source' is null then a new Map is created and returned. If 'target' - * is null then no content is added to the 'source' Map or newly created + * If 'source' is null then a new Map is created and returned. If 'target' is null then no content is added to the 'source' Map or newly created * Map. * </p> * * @param source The Map to merge in the target Map. - * @param target The Map in which the source Map will be merged (through - * addAll). - * @param override If an key from the source map already exists in the target - * map, should it override (true) or not (false) the value. - * @return The target Map with addition of source Map elements, or a new Map - * (including content of source set) if target was null. + * @param target The Map in which the source Map will be merged (through addAll). + * @param override If an key from the source map already exists in the target map, should it override (true) or not (false) the value. + * @return The target Map with addition of source Map elements, or a new Map (including content of source set) if target was null. */ public static <T, V> Map<T, V> merge(Map<T, ? extends V> source, Map<T, V> target, boolean override) { if (target == null) { target = new HashMap(); } - if (source != null) { for (Entry<T, ? extends V> entry : source.entrySet()) { if (override || !target.containsKey(entry.getKey())) { @@ -97,8 +87,7 @@ public final class CollectionUtils { } /** - * Merge two lists, the merge is performed based on the contains method so - * elements presents both in source and target are not added twice to the + * Merge two lists, the merge is performed based on the contains method so elements presents both in source and target are not added twice to the * list. * * @param source The source list. @@ -107,24 +96,20 @@ public final class CollectionUtils { */ public static <T> List<T> merge(List<T> source, List<T> target) { List<T> merged = target == null ? new ArrayList<>() : target; - if (source == null) { return merged; } - for (T t : source) { if (!merged.contains(t)) { merged.add(t); } } - return merged; } /** - * Returns a new list containing the second list appended to the - * first list. The {@link List#addAll(Collection)} operation is - * used to append the two given lists into a new list. + * Returns a new list containing the second list appended to the first list. The {@link List#addAll(Collection)} operation is used to append the + * two given lists into a new list. * * @param list1 the first list * @param list2 the second list |