final int newOrder = getNewOrder(order); final int oldOrder = getItemOrder() == null ? Integer.MAX_VALUE : getItemOrder().intValue(); if (newOrder != oldOrder) { final boolean moveUp = newOrder > oldOrder; for (final Item otherItem : getSection().getAssociatedItemsSet()) { if (otherItem != this) { final int otherOrder = otherItem.getItemOrder().intValue(); if (moveUp) { if (otherOrder > oldOrder && otherOrder <= newOrder) { otherItem.setItemOrder(Integer.valueOf(otherOrder - 1)); } } else { if (otherOrder >= newOrder && otherOrder < oldOrder) { otherItem.setItemOrder(Integer.valueOf(otherOrder + 1)); } } } } setItemOrder(Integer.valueOf(newOrder)); }
int newOrder = getNewOrder(order); if (getItemOrder() == null) { setItemOrder(Integer.valueOf(Integer.MAX_VALUE)); } if (getItemOrder() != null) { final int oldOrder = getItemOrder().intValue(); final boolean moveUp = newOrder > oldOrder; if (moveUp && order != null) { newOrder--; } if (newOrder != oldOrder) { for (final Item otherItem : getSection().getAssociatedItemsSet()) { if (this != otherItem) { final int otherOrder = otherItem.getItemOrder().intValue(); if (moveUp) { if (otherOrder > oldOrder && otherOrder <= newOrder) { otherItem.setItemOrder(Integer.valueOf(otherOrder - 1)); } } else { if (otherOrder >= newOrder && otherOrder < oldOrder) { otherItem.setItemOrder(Integer.valueOf(otherOrder + 1)); } } } } } }  setItemOrder(Integer.valueOf(newOrder));
    public void edit(final MultiLanguageString name, final MultiLanguageString information, final Boolean urgent,            final Integer order) {        if (name == null) {            throw new NullPointerException();        }        setName(name);        setInformation(information);        setUrgent(urgent == null ? Boolean.FALSE : Boolean.TRUE);        final int newOrder = getNewOrder(order);        final int oldOrder = getItemOrder() == null ? Integer.MAX_VALUE : getItemOrder().intValue();        if (newOrder != oldOrder) {            final boolean moveUp = newOrder > oldOrder;            for (final Item otherItem : getSection().getAssociatedItemsSet()) {                if (otherItem != this) {                    final int otherOrder = otherItem.getItemOrder().intValue();                    if (moveUp) {                        if (otherOrder > oldOrder && otherOrder <= newOrder) {                            otherItem.setItemOrder(Integer.valueOf(otherOrder - 1));                        }                    } else {                        if (otherOrder >= newOrder && otherOrder < oldOrder) {                            otherItem.setItemOrder(Integer.valueOf(otherOrder + 1));                        }                    }                }            }            setItemOrder(Integer.valueOf(newOrder));        }    }