Java List Move Item addRemoveChangeToString(int from, int to, List list, List removed)

Here you can find the source of addRemoveChangeToString(int from, int to, List list, List removed)

Description

add Remove Change To String

License

Open Source License

Declaration

public static String addRemoveChangeToString(int from, int to, List<?> list, List<?> removed) 

Method Source Code

//package com.java2s;
/*// w  ww .  jav  a 2 s .c om
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

import java.util.List;

public class Main {
    public static String addRemoveChangeToString(int from, int to, List<?> list, List<?> removed) {
        StringBuilder b = new StringBuilder();

        if (removed.isEmpty()) {
            b.append(list.subList(from, to));
            b.append(" added at ").append(from);
        } else {
            b.append(removed);
            if (from == to) {
                b.append(" removed at ").append(from);
            } else {
                b.append(" replaced by ");
                b.append(list.subList(from, to));
                b.append(" at ").append(from);
            }
        }
        return b.toString();
    }
}

Related

  1. canMoveUp(List list, int[] indices)
  2. getLongestLine(String text, List partsToRemove, String separator)
  3. getRemoveAll(List list1, Collection list2)
  4. minus(List initialList, List elementsToRemove)