Java List Move Item moveItemIdInSecond(final List list)

Here you can find the source of moveItemIdInSecond(final List list)

Description

move Item Id In Second

License

Open Source License

Declaration

private static List<String> moveItemIdInSecond(final List<String> list) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Jens Kristian Villadsen.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html/*www  .  j a  v a  2  s  .  c  om*/
 * 
 * Contributors:
 *     Jens Kristian Villadsen - Lead developer, owner and creator
 ******************************************************************************/

import java.util.List;

public class Main {
    private static List<String> moveItemIdInSecond(final List<String> list) {
        final boolean noItemKind = moveItemKindInFirst(list);
        if (list.contains("dmap.itemid")) {
            if (list.size() > 1) {
                list.remove("dmap.itemid");
                int index = 1;
                if (noItemKind) {
                    index = 0;
                }

                list.add(index, "dmap.itemid");
            }
        }
        return list;
    }

    private static boolean moveItemKindInFirst(final List<String> list) {
        boolean noItemKind = true;
        if (list.contains("dmap.itemkind")) {
            list.remove("dmap.itemkind");
            list.add(0, "dmap.itemkind");
            noItemKind = false;
        }
        return noItemKind;
    }
}

Related

  1. moveDownItems(List list, int[] positions)
  2. moveElementInList(List list, int targetIndex, int sourceIndex)
  3. moveElementToIndex( List list, ELEMENT fromElement, ELEMENT toElement)
  4. moveInList(List list, int index, T listItem)
  5. moveItem(List list, Object oldItem, int newIndex)
  6. moveItems(List list, int[] indices, int moveby, boolean up)
  7. moveLeft(int offset, T element, List list)
  8. moveOnePositionUp(final List list, final T object)
  9. moveRight(int offset, T element, List list)

  10. HOME | Copyright © www.java2s.com 2016