-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
OpenOptions.java
55 lines (47 loc) · 1.38 KB
/
OpenOptions.java
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
package liquibase.resource;
/**
* Defines the options for opening {@link Resource}s in Liquibase.
*/
public class OpenOptions {
private boolean truncate;
private boolean createIfNeeded;
/**
* Use default options of truncate = true, createIfNeeded = true;
*/
public OpenOptions() {
this.truncate = true;
this.createIfNeeded = true;
}
/**
* Should an existing file be truncated when opened. Both this and {@link #isAppend()}
* are automatically kept in sync with each other.
*/
public boolean isTruncate() {
return truncate;
}
public OpenOptions setTruncate(boolean truncate) {
this.truncate = truncate;
return this;
}
/**
* Should an existing file be appended to when opened. Both this and {@link #isTruncate()}
* are automatically kept in sync with each other.
*/
public boolean isAppend() {
return !isTruncate();
}
public OpenOptions setAppend(boolean append) {
this.truncate = !append;
return this;
}
/**
* If true, create the resource if it does not exist. If false, do not create the resource.
*/
public boolean isCreateIfNeeded() {
return createIfNeeded;
}
public OpenOptions setCreateIfNeeded(boolean createIfNeeded) {
this.createIfNeeded = createIfNeeded;
return this;
}
}