]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.acorn/src/org/simantics/acorn/FileCache.java
Fixing problems in the database unit testing environment with Acorn
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / FileCache.java
1 package org.simantics.acorn;
2
3 import java.nio.file.Path;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 import org.simantics.db.Disposable;
8
9 /**
10  * @author Tuukka Lehtonen
11  * @since 1.32.0
12  */
13 public class FileCache implements Disposable {
14
15         private Map<Path, FileIO> map = new HashMap<>();
16
17         public FileIO get(Path path) {
18                 synchronized (map) {
19                         return map.computeIfAbsent(path, FileIO::new);
20                 }
21         }
22
23         @Override
24         public void dispose() {
25                 map = new HashMap<>();
26         }
27
28 }