001    /*
002      GRANITE DATA SERVICES
003      Copyright (C) 2012 GRANITE DATA SERVICES S.A.S.
004    
005      This file is part of Granite Data Services.
006    
007      Granite Data Services is free software; you can redistribute it and/or modify
008      it under the terms of the GNU Library General Public License as published by
009      the Free Software Foundation; either version 2 of the License, or (at your
010      option) any later version.
011    
012      Granite Data Services is distributed in the hope that it will be useful, but
013      WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014      FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
015      for more details.
016    
017      You should have received a copy of the GNU Library General Public License
018      along with this library; if not, see <http://www.gnu.org/licenses/>.
019    */
020    
021    package org.granite.client.persistence.javafx;
022    
023    import java.util.List;
024    
025    import javafx.collections.ListChangeListener;
026    import javafx.collections.ObservableList;
027    
028    /**
029     * @author William DRAI
030     */
031    public class ListChangeWrapper<T> extends ListChangeListener.Change<T> {
032            
033        private final ListChangeListener.Change<? extends T> wrappedChange;
034        
035        private static final int[] EMPTY_PERMUTATION = new int[0];
036        
037        public ListChangeWrapper(ObservableList<T> list, ListChangeListener.Change<? extends T> wrappedChange) {
038            super(list);
039            this.wrappedChange = wrappedChange;
040        }
041    
042        @Override
043            public int getAddedSize() {
044                    return wrappedChange.getAddedSize();
045            }
046    
047            @SuppressWarnings("unchecked")
048            @Override
049            public List<T> getAddedSubList() {
050                    return (List<T>)wrappedChange.getAddedSubList();
051            }
052    
053            @Override
054            public int getRemovedSize() {
055                    return wrappedChange.getRemovedSize();
056            }
057    
058            @Override
059            public boolean wasAdded() {
060                    return wrappedChange.wasAdded();
061            }
062    
063            @Override
064            public boolean wasPermutated() {
065                    return wrappedChange.wasPermutated();
066            }
067    
068            @Override
069            public boolean wasRemoved() {
070                    return wrappedChange.wasRemoved();
071            }
072    
073            @Override
074            public boolean wasReplaced() {
075                    return wrappedChange.wasReplaced();
076            }
077    
078            @Override
079            public boolean wasUpdated() {
080                    return wrappedChange.wasUpdated();
081            }
082    
083        @Override
084        public int getFrom() {
085            return wrappedChange.getFrom();
086        }
087    
088        @Override
089        public int getTo() {
090            return wrappedChange.getTo();
091        }
092    
093        @Override
094        protected int[] getPermutation() {
095            return EMPTY_PERMUTATION;
096        }
097    
098        @Override
099        public int getPermutation(int num) {
100            return wrappedChange.getPermutation(num);
101        }
102    
103        @SuppressWarnings("unchecked")
104            @Override
105        public List<T> getRemoved() {
106            return (List<T>)wrappedChange.getRemoved();
107        }
108    
109        @Override
110        public boolean next() {
111            return wrappedChange.next();
112        }
113    
114        @Override
115        public void reset() {
116            wrappedChange.reset();
117        }        
118    }