Here you can find the source of createUniqueProducts(List
Parameter | Description |
---|---|
existingRecommendations | existing recommendations that will get the appended data |
newlyFetchedRecommendations | recommendations to be appended (if not already present) |
public static List<String> createUniqueProducts(List<String> list1, List<String> list2)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w.ja va 2s . c o m*/ * Appends the newly fetched recommendation resources (that are not already contained) to the end of the list * @param existingRecommendations existing recommendations that will get the appended data * @param newlyFetchedRecommendations recommendations to be appended (if not already present) */ public static List<String> createUniqueProducts(List<String> list1, List<String> list2) { List<String> uniqueList = new ArrayList<String>(); if (list1 != null) { for (String recommendedProduct : list1) { if (!uniqueList.contains(recommendedProduct)) { uniqueList.add(recommendedProduct); } } } if (list2 != null) { for (String recommendedProduct : list2) { if (!uniqueList.contains(recommendedProduct)) { uniqueList.add(recommendedProduct); } } } return uniqueList; } }