-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathLibraryResolvers.java
More file actions
44 lines (36 loc) · 1.26 KB
/
Copy pathLibraryResolvers.java
File metadata and controls
44 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package datadog.nativeloader;
import java.net.URL;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public final class LibraryResolvers {
private LibraryResolvers() {}
public static final LibraryResolver defaultLibraryResolver() {
return flatDirs();
}
public static final LibraryResolver withPreloaded(
LibraryResolver baseResolver, String... preloadedLibNames) {
return withPreloaded(baseResolver, new HashSet<>(Arrays.asList(preloadedLibNames)));
}
public static final LibraryResolver withPreloaded(
LibraryResolver baseResolver, Set<String> preloadedLibNames) {
return new LibraryResolver() {
@Override
public boolean isPreloaded(PlatformSpec platform, String libName) {
return preloadedLibNames.contains(libName);
}
@Override
public URL resolve(
PathLocator pathLocator, String component, PlatformSpec platformSpec, String libName)
throws Exception {
return baseResolver.resolve(pathLocator, component, platformSpec, libName);
}
};
}
public static final LibraryResolver flatDirs() {
return FlatDirLibraryResolver.INSTANCE;
}
public static final LibraryResolver nestedDirs() {
return NestedDirLibraryResolver.INSTANCE;
}
}