Java List Move Item moveRows(final List allRows, final List rowsToMove, final int index)

Here you can find the source of moveRows(final List allRows, final List rowsToMove, final int index)

Description

move Rows

License

Apache License

Declaration

public static <T> void moveRows(final List<T> allRows, final List<T> rowsToMove, final int index) 

Method Source Code


//package com.java2s;
/*/*  www  .  ja  v a2 s  .c  om*/
 * Copyright 2017 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

public class Main {
    public static <T> void moveRows(final List<T> allRows, final List<T> rowsToMove, final int index) {
        final int oldBlockStart = allRows.indexOf(rowsToMove.get(0));

        allRows.removeAll(rowsToMove);

        if (index < oldBlockStart) {
            allRows.addAll(index, rowsToMove);
        } else if (index > oldBlockStart) {
            allRows.addAll(index - rowsToMove.size() + 1, rowsToMove);
        }
    }
}

Related

  1. moveItemIdInSecond(final List list)
  2. moveItems(List list, int[] indices, int moveby, boolean up)
  3. moveLeft(int offset, T element, List list)
  4. moveOnePositionUp(final List list, final T object)
  5. moveRight(int offset, T element, List list)
  6. moveToFront(List aList, Object anObj)
  7. moveTop(List list, int[] indices)
  8. moveUp(final List list, final T toMoveUp)
  9. moveUp(List list, List toMoveUp)

    HOME | Copyright © www.java2s.com 2016