Ignore:
Timestamp:
2014-07-14T04:18:06+02:00 (10 years ago)
Author:
donvip
Message:

[josm_plugins] fix compilation warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagerycache/src/org/mapdb/EngineWrapper.java

    r29484 r30532  
    1414 *  limitations under the License.
    1515 */
    16 
    1716package org.mapdb;
    18 
    1917
    2018import java.io.IOError;
     
    2624import java.util.concurrent.ConcurrentLinkedQueue;
    2725
    28 
    2926/**
    3027 * EngineWrapper adapter. It implements all methods on Engine interface.
     
    293290    }
    294291
    295 
    296292    /**
    297293     * check if Record Instances were not modified while in cache.
    298294     * Usuful to diagnose strange problems with Instance Cache.
    299295     */
    300     public static class ImmutabilityCheckEngine extends EngineWrapper{
    301 
    302         protected static class Item {
    303             final Serializer serializer;
    304             final Object item;
     296    public static class ImmutabilityCheckEngine extends EngineWrapper {
     297
     298        protected static class Item<E> {
     299            final Serializer<E> serializer;
     300            final E item;
    305301            final int oldChecksum;
    306302
    307             public Item(Serializer serializer, Object item) {
     303            public Item(Serializer<E> serializer, E item) {
    308304                if(item==null || serializer==null) throw new AssertionError("null");
    309305                this.serializer = serializer;
     
    313309            }
    314310
    315             private int checksum(){
     311            private int checksum() {
    316312                try {
    317313                    DataOutput2 out = new DataOutput2();
     
    324320            }
    325321
    326             void check(){
     322            void check() {
    327323                int newChecksum = checksum();
    328324                if(oldChecksum!=newChecksum) throw new AssertionError("Record instance was modified: \n  "+item+"\n  "+serializer);
     
    330326        }
    331327
    332         protected LongConcurrentHashMap<Item> items = new LongConcurrentHashMap<Item>();
     328        protected LongConcurrentHashMap<Item<?>> items = new LongConcurrentHashMap<>();
    333329
    334330        protected ImmutabilityCheckEngine(Engine engine) {
     
    338334        @Override
    339335        public <A> A get(long recid, Serializer<A> serializer) {
    340             Item item = items.get(recid);
     336            Item<?> item = items.get(recid);
    341337            if(item!=null) item.check();
    342338            A ret = super.get(recid, serializer);
    343             if(ret!=null) items.put(recid, new Item(serializer,ret));
     339            if(ret!=null) items.put(recid, new Item<A>(serializer,ret));
    344340            return ret;
    345341        }
     
    348344        public <A> long put(A value, Serializer<A> serializer) {
    349345            long ret =  super.put(value, serializer);
    350             if(value!=null) items.put(ret, new Item(serializer,value));
     346            if(value!=null) items.put(ret, new Item<A>(serializer,value));
    351347            return ret;
    352348        }
     
    354350        @Override
    355351        public <A> void update(long recid, A value, Serializer<A> serializer) {
    356             Item item = items.get(recid);
     352            Item<?> item = items.get(recid);
    357353            if(item!=null) item.check();
    358354            super.update(recid, value, serializer);
    359             if(value!=null) items.put(recid, new Item(serializer,value));
    360         }
    361 
     355            if(value!=null) items.put(recid, new Item<A>(serializer,value));
     356        }
     357
     358        @SuppressWarnings({ "unchecked", "rawtypes" })
    362359        @Override
    363360        public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer) {
    364             Item item = items.get(recid);
     361            Item<?> item = items.get(recid);
    365362            if(item!=null) item.check();
    366363            boolean ret = super.compareAndSwap(recid, expectedOldValue, newValue, serializer);
     
    372369        public void close() {
    373370            super.close();
    374             for(Iterator<Item> iter = items.valuesIterator(); iter.hasNext();){
     371            for(Iterator<Item<?>> iter = items.valuesIterator(); iter.hasNext();){
    375372                iter.next().check();
    376373            }
     
    378375        }
    379376    }
    380    
    381377   
    382378    /** Engine wrapper with all methods synchronized on global lock, useful to diagnose concurrency issues.*/
     
    442438        }
    443439    }
    444 
    445440}
Note: See TracChangeset for help on using the changeset viewer.