Skip to content

Commit abc31d5

Browse files
committed
lint for checkstyle
1 parent 2f39b37 commit abc31d5

12 files changed

Lines changed: 852 additions & 831 deletions

File tree

‎.gitignore‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,7 @@ Temporary Items
203203
.apdisk
204204

205205
# Ignore docs/_build
206-
docs/_build
206+
docs/_build
207+
208+
# VScode
209+
.vscode

‎src/main/java/io/delta/sharing/java/DeltaSharing.java‎

Lines changed: 231 additions & 223 deletions
Large diffs are not rendered by default.
Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package io.delta.sharing.java;
22

3-
import io.delta.sharing.java.adaptor.DeltaSharingJSONProvider;
3+
import io.delta.sharing.java.adaptor.DeltaSharingJsonProvider;
44
import io.delta.sharing.spark.DeltaSharingProfileProvider;
55
import io.delta.sharing.spark.DeltaSharingRestClient;
6-
76
import java.io.IOException;
87
import java.nio.file.Files;
98
import java.nio.file.Path;
@@ -12,45 +11,51 @@
1211
import java.util.HashMap;
1312

1413
/**
15-
* Factory class for {@link DeltaSharing}.
16-
* It provides different constructors that might be appropriate in different situations.
14+
* Factory class for {@link DeltaSharing}. It provides different constructors that might be
15+
* appropriate in different situations.
1716
*/
1817
public class DeltaSharingFactory {
1918

20-
/**
21-
* Constructor
22-
* @param profileProvider An instance of {@link DeltaSharingProfileProvider}.
23-
* @param checkpointPath An path to a temporary checkpoint location.
24-
* @return An instance of {@link DeltaSharing} client.
25-
* @throws IOException Transitive due to the call to {@link Files#createTempDirectory(String, FileAttribute[])}.
26-
*/
27-
public static DeltaSharing create(DeltaSharingProfileProvider profileProvider, Path checkpointPath) throws IOException {
28-
DeltaSharing instance = new DeltaSharing();
29-
instance.profileProvider = profileProvider;
30-
instance.httpClient = new DeltaSharingRestClient(profileProvider, 120, 4, false);
31-
instance.checkpointPath = checkpointPath;
32-
instance.metadataMap = new HashMap<>();
33-
if (!Files.exists(checkpointPath)) {
34-
Files.createDirectory(instance.checkpointPath);
35-
}
36-
instance.tempDir = Files.createTempDirectory(instance.checkpointPath, "delta_sharing");
37-
instance.tempDir.toFile().deleteOnExit();
38-
return instance;
19+
/**
20+
* Constructor.
21+
*
22+
* @param profileProvider An instance of {@link DeltaSharingProfileProvider}.
23+
* @param checkpointPath An path to a temporary checkpoint location.
24+
* @return An instance of {@link DeltaSharing} client.
25+
* @throws IOException Transitive due to the call to
26+
* {@link Files#createTempDirectory(String, FileAttribute[])}.
27+
*/
28+
public static DeltaSharing create(DeltaSharingProfileProvider profileProvider,
29+
Path checkpointPath) throws IOException {
30+
DeltaSharing instance = new DeltaSharing();
31+
instance.profileProvider = profileProvider;
32+
instance.httpClient = new DeltaSharingRestClient(profileProvider, 120, 4, false);
33+
instance.checkpointPath = checkpointPath;
34+
instance.metadataMap = new HashMap<>();
35+
if (!Files.exists(checkpointPath)) {
36+
Files.createDirectory(instance.checkpointPath);
3937
}
38+
instance.tempDir = Files.createTempDirectory(instance.checkpointPath, "delta_sharing");
39+
instance.tempDir.toFile().deleteOnExit();
40+
return instance;
41+
}
4042

41-
/**
42-
* Constructor
43-
* @param providerConf A valid JSON document corresponding to {@link DeltaSharingProfileProvider}.
44-
* @param checkpointLocation A string containing a path to be used as a checkpoint location.
45-
* @return An instance of {@link DeltaSharing} client.
46-
* @throws IOException Transitive due to the call to {@link Files#createDirectories(Path, FileAttribute[])}.
47-
*/
48-
public static DeltaSharing create(String providerConf, String checkpointLocation) throws IOException {
49-
Path checkpointPath = Paths.get(checkpointLocation);
50-
if(!Files.exists(checkpointPath)){
51-
Files.createDirectories(checkpointPath);
52-
}
53-
DeltaSharingProfileProvider profileProvider = new DeltaSharingJSONProvider(providerConf);
54-
return create(profileProvider, checkpointPath);
43+
/**
44+
* Constructor.
45+
*
46+
* @param providerConf A valid JSON document corresponding to {@link DeltaSharingProfileProvider}.
47+
* @param checkpointLocation A string containing a path to be used as a checkpoint location.
48+
* @return An instance of {@link DeltaSharing} client.
49+
* @throws IOException Transitive due to the call to
50+
* {@link Files#createDirectories(Path, FileAttribute[])}.
51+
*/
52+
public static DeltaSharing create(String providerConf, String checkpointLocation)
53+
throws IOException {
54+
Path checkpointPath = Paths.get(checkpointLocation);
55+
if (!Files.exists(checkpointPath)) {
56+
Files.createDirectories(checkpointPath);
5557
}
58+
DeltaSharingProfileProvider profileProvider = new DeltaSharingJsonProvider(providerConf);
59+
return create(profileProvider, checkpointPath);
60+
}
5661
}

‎src/main/java/io/delta/sharing/java/adaptor/DeltaSharingJSONProvider.java‎

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,54 @@
77

88

99
/**
10-
* Loads {@link io.delta.sharing.spark.DeltaSharingProfileProvider} based on configuration provided as a JSON document.
11-
* JSON document has to be a valid profile file document.
12-
* Required fields are checked inside the constructor method and the object creation will fail in case of breaking the constraints.
13-
* <p>
10+
* Loads {@link io.delta.sharing.spark.DeltaSharingProfileProvider} based on configuration provided
11+
* as a JSON document. JSON document has to be a valid profile file document. Required fields are
12+
* checked inside the constructor method and the object creation will fail in case of breaking the
13+
* constraints.
14+
* <p/>
1415
*
1516
* @author Milos Colic
16-
* @see DeltaSharingProfileAdaptor DeltaSharingProfileAdaptor used for object mapping when parsing JSON.
17+
* @see DeltaSharingProfileAdaptor DeltaSharingProfileAdaptor used for object mapping when parsing
18+
* JSON.
1719
* @since 0.1.0
1820
*/
19-
public class DeltaSharingJSONProvider implements DeltaSharingProfileProvider {
20-
String configuration;
21-
DeltaSharingProfile profile;
21+
public class DeltaSharingJsonProvider implements DeltaSharingProfileProvider {
22+
String configuration;
23+
DeltaSharingProfile profile;
2224

23-
/**
24-
* Constructor method that expects Configuration JSON.
25-
* JSON file must contain endpoint, bearerToken and shareCredentialsVersion fields.
26-
* Object creation will fail if shareCredentialsVersion is too new.
27-
*
28-
* @param conf A valid JSON object.
29-
*/
30-
public DeltaSharingJSONProvider(String conf) throws JsonProcessingException {
31-
try {
32-
configuration = conf;
33-
ObjectMapper mapper = new ObjectMapper();
34-
DeltaSharingProfileAdaptor profileAdaptor = mapper.readValue(configuration, DeltaSharingProfileAdaptor.class);
35-
profile = profileAdaptor.toProfile();
36-
} catch (Exception e) {
37-
System.out.print(e);
38-
throw e;
39-
}
25+
/**
26+
* Constructor method that expects Configuration JSON. JSON file must contain endpoint,
27+
* bearerToken and shareCredentialsVersion fields. Object creation will fail if
28+
* shareCredentialsVersion is too new.
29+
*
30+
* @param conf A valid JSON object.
31+
*/
32+
public DeltaSharingJsonProvider(String conf) throws JsonProcessingException {
33+
try {
34+
configuration = conf;
35+
ObjectMapper mapper = new ObjectMapper();
36+
DeltaSharingProfileAdaptor profileAdaptor =
37+
mapper.readValue(configuration, DeltaSharingProfileAdaptor.class);
38+
profile = profileAdaptor.toProfile();
39+
} catch (Exception e) {
40+
System.out.print(e);
41+
throw e;
42+
}
4043

41-
if ((int) profile.shareCredentialsVersion().get() > DeltaSharingProfile.CURRENT()) {
42-
throw new IllegalArgumentException(
43-
"'shareCredentialsVersion' in the profile is " +
44-
"${profile.shareCredentialsVersion.get} which is too new. The current release " +
45-
"supports version ${DeltaSharingProfile.CURRENT} and below. Please upgrade to a newer " +
46-
"release.");
47-
}
48-
if (profile.endpoint() == null) {
49-
throw new IllegalArgumentException("Cannot find the 'endpoint' field in the profile file");
50-
}
44+
if ((int) profile.shareCredentialsVersion().get() > DeltaSharingProfile.CURRENT()) {
45+
throw new IllegalArgumentException("'shareCredentialsVersion' in the profile is "
46+
+ "${profile.shareCredentialsVersion.get} which is too new. The current release "
47+
+ "supports version ${DeltaSharingProfile.CURRENT} and below. Please upgrade to a newer "
48+
+ "release.");
49+
}
50+
if (profile.endpoint() == null) {
51+
throw new IllegalArgumentException("Cannot find the 'endpoint' field in the profile file");
5152
}
53+
}
5254

5355

54-
@Override
55-
public DeltaSharingProfile getProfile() {
56-
return profile;
57-
}
58-
}
56+
@Override
57+
public DeltaSharingProfile getProfile() {
58+
return profile;
59+
}
60+
}

‎src/main/java/io/delta/sharing/java/adaptor/DeltaSharingProfileAdaptor.java‎

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,73 @@
44
import scala.Option;
55

66
/**
7-
* Used for Jackson JSON parsing and object mapping.
8-
* POJO corresponding to profile file format.
7+
* Used for Jackson JSON parsing and object mapping. POJO corresponding to profile file format.
98
* Update when the format of profile file changes.
10-
* @implNote Suppress is added because of all the getters and setters are required to be explicitly created for Jackson
11-
* to parse JSONs correctly. However warnings are shown since getters and setters are not explicitly tests.
12-
* @author Milos Colic
13-
* @since 0.1.0
9+
*
10+
* @implNote Suppress is added because of all the getters and setters are required to be explicitly
11+
* created for Jackson to parse JSONs correctly. However warnings are shown since getters
12+
* and setters are not explicitly tests.
13+
* @author Milos Colic
14+
* @since 0.1.0
1415
*/
15-
@SuppressWarnings("unused")
1616
public class DeltaSharingProfileAdaptor {
17-
int shareCredentialsVersion;
18-
String endpoint;
19-
String bearerToken;
20-
String expirationTime;
17+
int shareCredentialsVersion;
18+
String endpoint;
19+
String bearerToken;
20+
String expirationTime;
2121

22-
/** Default constructor. */
23-
public DeltaSharingProfileAdaptor() { }
22+
/** Default constructor. */
23+
public DeltaSharingProfileAdaptor() {}
2424

25-
/** Getter for shareCredentialsVersion. */
26-
public int getShareCredentialsVersion() {
27-
return shareCredentialsVersion;
28-
}
25+
/** Getter for shareCredentialsVersion. */
26+
public int getShareCredentialsVersion() {
27+
return shareCredentialsVersion;
28+
}
2929

30-
/** Setter for shareCredentialsVersion. */
31-
public void setShareCredentialsVersion(int shareCredentialsVersion) {
32-
this.shareCredentialsVersion = shareCredentialsVersion;
33-
}
30+
/** Setter for shareCredentialsVersion. */
31+
public void setShareCredentialsVersion(int shareCredentialsVersion) {
32+
this.shareCredentialsVersion = shareCredentialsVersion;
33+
}
3434

35-
/** Getter for endpoint. */
36-
public String getEndpoint() {
37-
return endpoint;
38-
}
35+
/** Getter for endpoint. */
36+
public String getEndpoint() {
37+
return endpoint;
38+
}
3939

40-
/** Setter for endpoint. */
41-
public void setEndpoint(String endpoint) {
42-
this.endpoint = endpoint;
43-
}
40+
/** Setter for endpoint. */
41+
public void setEndpoint(String endpoint) {
42+
this.endpoint = endpoint;
43+
}
4444

45-
/** Getter for bearerToken. */
46-
public String getBearerToken() {
47-
return bearerToken;
48-
}
45+
/** Getter for bearerToken. */
46+
public String getBearerToken() {
47+
return bearerToken;
48+
}
4949

50-
/** Setter for bearerToken. */
51-
public void setBearerToken(String bearerToken) {
52-
this.bearerToken = bearerToken;
53-
}
50+
/** Setter for bearerToken. */
51+
public void setBearerToken(String bearerToken) {
52+
this.bearerToken = bearerToken;
53+
}
5454

55-
/** Getter for expirationTime. */
56-
public String getExpirationTime() {
57-
return expirationTime;
58-
}
55+
/** Getter for expirationTime. */
56+
public String getExpirationTime() {
57+
return expirationTime;
58+
}
5959

60-
/** Setter for expirationTime. */
61-
public void setExpirationTime(String expirationTime) {
62-
this.expirationTime = expirationTime;
63-
}
60+
/** Setter for expirationTime. */
61+
public void setExpirationTime(String expirationTime) {
62+
this.expirationTime = expirationTime;
63+
}
6464

65-
/**
66-
* Java wrapper method that can generate Scala paired object.
67-
* This is need to be able to abstract from cross language APIs.
68-
* @return An equivalent instance of Scala {@link io.delta.sharing.spark.DeltaSharingProfile} class.
69-
*/
70-
public DeltaSharingProfile toProfile() {
71-
return DeltaSharingProfile.apply(Option.apply(shareCredentialsVersion), endpoint, bearerToken, expirationTime);
72-
}
65+
/**
66+
* Java wrapper method that can generate Scala paired object. This is need to be able to abstract
67+
* from cross language APIs.
68+
*
69+
* @return An equivalent instance of Scala {@link io.delta.sharing.spark.DeltaSharingProfile}
70+
* class.
71+
*/
72+
public DeltaSharingProfile toProfile() {
73+
return DeltaSharingProfile.apply(Option.apply(shareCredentialsVersion), endpoint, bearerToken,
74+
expirationTime);
75+
}
7376
}

0 commit comments

Comments
 (0)