src/main/java/tuupertunut/hintahaku/event/ChangeListenableConnector.java
/* This is meant to be called from a list event listener only once per
     * event. This converts the ListEvent to a ChangeEvent. */
This is meant to be called from a list event listener only once per
event. This converts the ListEvent to a ChangeEvent.
This is meant to be called from a list event listener only once per event . This converts the ListEvent to a ChangeEvent .
public ChangeEvent wrapListEvent(ListEvent<?> listEvent) {
        /* If this connector has a passed event stored, it means that the
         * ListEvent was caused by a ChangeEvent in one of the elements of the
         * list. In that case, a proxy event is returned with the passed event
         * as the cause. Otherwise, it means the list was structurally changed
         * and a root event is returned. */
        if (hasPassedEvent()) {
            return new ChangeEvent(listEvent.getSource(), consumePassedEvent(), "list update");
        } else {
            listEvent.next();
            /* Testing, if the list event has more than one change. */
            if (!listEvent.hasNext()) {
                switch (listEvent.getType()) {
                    case ListEvent.UPDATE:
                        return new ChangeEvent(listEvent.getSource(), "list update", "unknown value", "unknown value");
                    case ListEvent.DELETE:
                        return new ChangeEvent(listEvent.getSource(), "list delete", "unknown value", null);
                    case ListEvent.INSERT:
                        return new ChangeEvent(listEvent.getSource(), "list insert", null, "unknown value");
                    default:
                        throw new IllegalArgumentException();
                }
            } else {
                return new ChangeEvent(listEvent.getSource(), "list update", "multiple unknown values", "multiple unknown values");
            }
        }
    }
public ChangeEvent wrapListEvent ( ListEvent < ? > listEvent ) { /* If this connector has a passed event stored, it means that the
         * ListEvent was caused by a ChangeEvent in one of the elements of the
         * list. In that case, a proxy event is returned with the passed event
         * as the cause. Otherwise, it means the list was structurally changed
         * and a root event is returned. */ if ( hasPassedEvent ( ) ) { return new ChangeEvent ( listEvent . getSource ( ) , consumePassedEvent ( ) , "list update" ) ; } else { listEvent . next ( ) ; /* Testing, if the list event has more than one change. */ if ( ! listEvent . hasNext ( ) ) { switch ( listEvent . getType ( ) ) { case ListEvent . UPDATE : return new ChangeEvent ( listEvent . getSource ( ) , "list update" , "unknown value" , "unknown value" ) ; case ListEvent . DELETE : return new ChangeEvent ( listEvent . getSource ( ) , "list delete" , "unknown value" , null ) ; case ListEvent . INSERT : return new ChangeEvent ( listEvent . getSource ( ) , "list insert" , null , "unknown value" ) ; default : throw new IllegalArgumentException ( ) ; } } else { return new ChangeEvent ( listEvent . getSource ( ) , "list update" , "multiple unknown values" , "multiple unknown values" ) ; } } }
This is meant to be called from a list event listener only once per
 event.
This is meant to be called from a list event listener only once per event .