-
Notifications
You must be signed in to change notification settings - Fork 6
/
FetchFromUrlMode.java
64 lines (54 loc) · 2.12 KB
/
FetchFromUrlMode.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
56
57
58
59
60
61
62
63
64
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - info@scireum.de
*/
package sirius.biz.storage.layer3;
import sirius.biz.jobs.params.EnumParameter;
import sirius.biz.jobs.params.Parameter;
import sirius.kernel.nls.NLS;
import java.net.URI;
import java.util.function.Predicate;
/**
* Determines the behavior of {@link VirtualFile#loadFromUrl(URI, FetchFromUrlMode)} or
* {@link VirtualFile#resolveOrLoadChildFromURL(URI, FetchFromUrlMode, Predicate)}.
*/
public enum FetchFromUrlMode {
/**
* Fetches the data from the URL if either the local file does not exist or if the contents on the remote server
* have been modified since the last fetch.
*/
NON_EXISTENT_OR_MODIFIED,
/**
* Only fetches the data from the server if the local file does not exist.
*/
NON_EXISTENT,
/**
* Always fetches the data from the server.
*/
ALWAYS_FETCH,
/**
* Never fetches any data from the server. Note that this will not perform any network request and thus for URLs
* which do not reveal the effective file name, <tt>VirtualFile.resolveOrLoadChildFromURL</tt> will fail with an
* appropriate error message.
*/
NEVER_FETCH;
/**
* Provides a parameter to be used to select the mode to use during an import job.
*/
public static final Parameter<FetchFromUrlMode> PARAMETER = createParameter();
private static Parameter<FetchFromUrlMode> createParameter() {
return new EnumParameter<>("fetchFromUrlMode",
"$FetchFromUrlMode.parameter.name",
FetchFromUrlMode.class).withDefault(FetchFromUrlMode.NON_EXISTENT_OR_MODIFIED)
.withDescription("$FetchFromUrlMode.parameter.description")
.markRequired()
.build();
}
@Override
public String toString() {
return NLS.get(getClass().getSimpleName() + "." + name());
}
}