-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathJarContentsBuilder.java
More file actions
58 lines (49 loc) · 1.52 KB
/
JarContentsBuilder.java
File metadata and controls
58 lines (49 loc) · 1.52 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cpw.mods.jarhandling;
import cpw.mods.jarhandling.impl.JarContentsImpl;
import cpw.mods.niofs.union.UnionPathFilter;
import org.jetbrains.annotations.Nullable;
import java.nio.file.Path;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.jar.Manifest;
/**
* Builder for {@link JarContents}.
*/
public final class JarContentsBuilder {
private Path[] paths = new Path[0];
private Supplier<Manifest> defaultManifest = Manifest::new;
@Nullable
private UnionPathFilter pathFilter = null;
public JarContentsBuilder() {}
/**
* Sets the root paths for the files of this jar.
*/
public JarContentsBuilder paths(Path... paths) {
this.paths = paths;
return this;
}
/**
* Overrides the default manifest for this jar.
* The default manifest is only used when the jar does not provide a manifest already.
*/
public JarContentsBuilder defaultManifest(Supplier<Manifest> manifest) {
Objects.requireNonNull(manifest);
this.defaultManifest = manifest;
return this;
}
/**
* Overrides the path filter for this jar, to exclude some entries from the underlying file system.
*
* @see UnionPathFilter
*/
public JarContentsBuilder pathFilter(@Nullable UnionPathFilter pathFilter) {
this.pathFilter = pathFilter;
return this;
}
/**
* Builds the jar.
*/
public JarContents build() {
return new JarContentsImpl(paths, defaultManifest, pathFilter);
}
}