OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 180 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 180 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.utils.cache;
14
 package org.openconcerto.utils.cache;
15
 
15
 
-
 
16
import org.openconcerto.utils.CollectionUtils;
16
import org.openconcerto.utils.IScheduledFutureTask;
17
import org.openconcerto.utils.IScheduledFutureTask;
17
 
18
 
18
import java.util.Collections;
19
import java.util.Collections;
19
import java.util.HashMap;
20
import java.util.HashMap;
20
import java.util.Iterator;
21
import java.util.Iterator;
21
import java.util.LinkedHashMap;
-
 
22
import java.util.List;
22
import java.util.List;
23
import java.util.Map;
23
import java.util.Map;
24
import java.util.Map.Entry;
24
import java.util.Map.Entry;
25
import java.util.Set;
25
import java.util.Set;
26
import java.util.concurrent.Callable;
26
import java.util.concurrent.Callable;
Line 176... Line 176...
176
        watcher.add(item);
176
        watcher.add(item);
177
        return watcher;
177
        return watcher;
178
    }
178
    }
179
 
179
 
180
    final synchronized Map<D, CacheWatcher<? super D>> watch(Set<? extends D> data, final CacheItem<?, ?, D> item) {
180
    final synchronized Map<D, CacheWatcher<? super D>> watch(Set<? extends D> data, final CacheItem<?, ?, D> item) {
181
        final Map<D, CacheWatcher<? super D>> res = new LinkedHashMap<D, CacheWatcher<? super D>>(data.size(), 1.0f);
181
        final Map<D, CacheWatcher<? super D>> res = CollectionUtils.newLinkedHashMap(data.size());
182
        for (final D d : data) {
182
        for (final D d : data) {
183
            final CacheWatcher<? super D> watcher = this.watch(d, item);
183
            final CacheWatcher<? super D> watcher = this.watch(d, item);
184
            if (watcher != null)
184
            if (watcher != null)
185
                res.put(d, watcher);
185
                res.put(d, watcher);
186
        }
186
        }