Java Utililty Methods List Create

List of utility methods to do List Create

Description

The list of methods to do List Create are organized into topic(s).

Method

ListcreateUniqueProducts(List list1, List list2)
Appends the newly fetched recommendation resources (that are not already contained) to the end of the list
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;
ListcreateUnmodifiableList(Collection coll)
create Unmodifiable List
List<T> aList;
if (coll == null || coll.size() == 0)
    aList = Collections.emptyList();
else {
    List<T> newList;
    if (coll.size() == 1) {
        T value = (coll instanceof List<?>) ? ((List<T>) coll).get(0) : coll.iterator().next();
        newList = Collections.singletonList(value);
...
StringcreateUpdateMeasurementItemList(final String itemList, final String updateItem)
Create the updated measurement ItemList depend on operation
String updateList = null;
List<String> list = new ArrayList<String>(Arrays.asList(itemList.split(",")));
if (list.indexOf(updateItem) == -1) {
    return itemList;
list.remove(list.indexOf(updateItem));
if (list.size() > 0) {
    updateList = list.get(0);
...
ListcreateValues(int barCount, String valueDigits, int distributionType, List valueCounts)
create Values
int digitCount = valueDigits.length();
assert (barCount <= (digitCount * digitCount));
List<String> values = new ArrayList<String>(barCount);
int iterations = barCount / digitCount;
int residual = barCount % digitCount;
for (int i = 0; i < digitCount; i++) {
    int currentIterations = iterations;
    if (i < residual) {
...
StringcreateWhereInClause(String field, List values, boolean isString)
create Where In Clause
if (field == null || field.isEmpty() || values == null || values.isEmpty()) {
    return "";
StringBuilder stringBuilder = new StringBuilder(field).append(" IN (");
int index = 0;
String separator;
if (isString) {
    separator = "', '";
...
List>createWidList(int[][] widArray)
Converts two dimensional integer (representing word ids) array into a list of lists.
List<List<Integer>> widList = new ArrayList<List<Integer>>();
for (int[] widArrayGroup : widArray) {
    List<Integer> widListGroup = new ArrayList<Integer>();
    for (int wid : widArrayGroup) {
        widListGroup.add(wid);
    widList.add(widListGroup);
return widList;
ListgetOrCreateList(Map> map, K key)
get Or Create List
List<T> set = map.get(key);
if (set == null) {
    set = new ArrayList<T>();
    map.put(key, set);
return set;