Skip to content

Commit 63d8ed3

Browse files
authored
docs: Javadocs for TransferManager interface and ParallelUploadConfig (#2094)
* docs: Javadocs for TransferManager interface and ParallelUploadConfig
1 parent 6769a2b commit 63d8ed3

File tree

3 files changed

+187
-36
lines changed

3 files changed

+187
-36
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/ParallelDownloadConfig.java

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
import java.util.Objects;
2929
import org.checkerframework.checker.nullness.qual.NonNull;
3030

31+
/**
32+
* Configuration for performing Parallel Downloads with {@link TransferManager}.
33+
*
34+
* @see Builder
35+
*/
3136
@BetaApi
3237
public final class ParallelDownloadConfig {
3338

@@ -48,26 +53,41 @@ private ParallelDownloadConfig(
4853
}
4954

5055
/**
51-
* A common prefix that is removed from downloaded object's name before written to the filesystem
56+
* A common prefix removed from an object's name before being written to the filesystem.
57+
*
58+
* @see Builder#setStripPrefix(String)
5259
*/
5360
@BetaApi
5461
public @NonNull String getStripPrefix() {
5562
return stripPrefix;
5663
}
5764

58-
/** The base directory in which all objects will be placed when downloaded. */
65+
/**
66+
* The base directory in which all objects will be placed when downloaded.
67+
*
68+
* @see Builder#setDownloadDirectory(Path)
69+
*/
5970
@BetaApi
6071
public @NonNull Path getDownloadDirectory() {
6172
return downloadDirectory;
6273
}
6374

64-
/** The bucket objects are being downloaded from */
75+
/**
76+
* The bucket objects are being downloaded from.
77+
*
78+
* @see Builder#setBucketName(String)
79+
*/
6580
@BetaApi
6681
public @NonNull String getBucketName() {
6782
return bucketName;
6883
}
6984

70-
/** A list of common BlobSourceOptions that are used for each download request */
85+
/**
86+
* A list of common BlobSourceOptions that are used for each download request. Note this list of
87+
* options will be applied to every single request.
88+
*
89+
* @see Builder#setOptionsPerRequest(List)
90+
*/
7191
@BetaApi
7292
public @NonNull List<BlobSourceOption> getOptionsPerRequest() {
7393
return optionsPerRequest;
@@ -103,6 +123,11 @@ public String toString() {
103123
.toString();
104124
}
105125

126+
/**
127+
* Builds an instance of ParallelDownloadConfig.
128+
*
129+
* @see ParallelDownloadConfig
130+
*/
106131
@BetaApi
107132
public static Builder newBuilder() {
108133
return new Builder();
@@ -123,30 +148,61 @@ private Builder() {
123148
this.optionsPerRequest = ImmutableList.of();
124149
}
125150

151+
/**
152+
* Sets the value for stripPrefix. This string will be removed from the beginning of all object
153+
* names before they are written to the filesystem.
154+
*
155+
* @return the builder instance with the value for stripPrefix modified.
156+
* @see ParallelDownloadConfig#getStripPrefix()
157+
*/
126158
@BetaApi
127159
public Builder setStripPrefix(String stripPrefix) {
128160
this.stripPrefix = stripPrefix;
129161
return this;
130162
}
131163

164+
/**
165+
* Sets the base directory on the filesystem that all objects will be written to.
166+
*
167+
* @return the builder instance with the value for downloadDirectory modified.
168+
* @see ParallelDownloadConfig#getDownloadDirectory()
169+
*/
132170
@BetaApi
133171
public Builder setDownloadDirectory(Path downloadDirectory) {
134172
this.downloadDirectory = downloadDirectory;
135173
return this;
136174
}
137175

176+
/**
177+
* Sets the bucketName that Transfer Manager will download from. This field is required.
178+
*
179+
* @return the builder instance with the value for bucketName modified.
180+
* @see ParallelDownloadConfig#getBucketName()
181+
*/
138182
@BetaApi
139183
public Builder setBucketName(String bucketName) {
140184
this.bucketName = bucketName;
141185
return this;
142186
}
143187

188+
/**
189+
* Sets the BlobSourceOptions that will be applied to each download request. Note these options
190+
* will be applied to every single download request.
191+
*
192+
* @return the builder instance with the value for OptionsPerRequest modified.
193+
* @see ParallelDownloadConfig#getOptionsPerRequest()
194+
*/
144195
@BetaApi
145196
public Builder setOptionsPerRequest(List<BlobSourceOption> optionsPerRequest) {
146197
this.optionsPerRequest = ImmutableList.copyOf(optionsPerRequest);
147198
return this;
148199
}
149200

201+
/**
202+
* Creates a ParallelDownloadConfig object.
203+
*
204+
* @return {@link ParallelDownloadConfig}
205+
*/
150206
@BetaApi
151207
public ParallelDownloadConfig build() {
152208
checkNotNull(bucketName);

google-cloud-storage/src/main/java/com/google/cloud/storage/transfermanager/ParallelUploadConfig.java

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,62 +19,74 @@
1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

2121
import com.google.api.core.BetaApi;
22-
import com.google.cloud.storage.Storage.BlobTargetOption;
2322
import com.google.cloud.storage.Storage.BlobWriteOption;
2423
import com.google.common.base.MoreObjects;
2524
import com.google.common.collect.ImmutableList;
2625
import java.util.List;
2726
import java.util.Objects;
2827
import org.checkerframework.checker.nullness.qual.NonNull;
2928

29+
/**
30+
* Configuration for performing Parallel Uploads with {@link TransferManager}.
31+
*
32+
* @see Builder
33+
*/
3034
@BetaApi
3135
public final class ParallelUploadConfig {
3236

3337
private final boolean skipIfExists;
3438
@NonNull private final String prefix;
3539
@NonNull private final String bucketName;
36-
@NonNull private final List<BlobTargetOption> targetOptsPerRequest;
3740

3841
@NonNull private final List<BlobWriteOption> writeOptsPerRequest;
3942

4043
private ParallelUploadConfig(
4144
boolean skipIfExists,
4245
@NonNull String prefix,
4346
@NonNull String bucketName,
44-
@NonNull List<BlobTargetOption> targetOptsPerRequest,
4547
@NonNull List<BlobWriteOption> writeOptsPerRequest) {
4648
this.skipIfExists = skipIfExists;
4749
this.prefix = prefix;
4850
this.bucketName = bucketName;
49-
this.targetOptsPerRequest = targetOptsPerRequest;
5051
this.writeOptsPerRequest = applySkipIfExists(skipIfExists, writeOptsPerRequest);
5152
}
5253

53-
/** If a corresponding object already exists skip uploading the object */
54+
/**
55+
* If set Transfer Manager will skip uploading an object if it already exists, equivalent to
56+
* providing {@link BlobWriteOption#doesNotExist()} in {@link #getWriteOptsPerRequest()}
57+
*
58+
* @see Builder#setSkipIfExists(boolean)
59+
*/
5460
@BetaApi
5561
public boolean isSkipIfExists() {
5662
return skipIfExists;
5763
}
5864

59-
/** A common prefix that will be applied to all object paths in the destination bucket */
65+
/**
66+
* A common prefix that will be applied to all object paths in the destination bucket
67+
*
68+
* @see Builder#setPrefix(String)
69+
*/
6070
@BetaApi
6171
public @NonNull String getPrefix() {
6272
return prefix;
6373
}
6474

65-
/** The bucket objects are being uploaded from */
75+
/**
76+
* The bucket objects are being uploaded from
77+
*
78+
* @see Builder#setBucketName(String)
79+
*/
6680
@BetaApi
6781
public @NonNull String getBucketName() {
6882
return bucketName;
6983
}
7084

71-
/** A list of common BlobTargetOptions that are used for each upload request */
72-
@BetaApi
73-
public @NonNull List<BlobTargetOption> getTargetOptsPerRequest() {
74-
return targetOptsPerRequest;
75-
}
76-
77-
/** A list of common BlobWriteOptions that are used for each upload request */
85+
/**
86+
* A list of common BlobWriteOptions, note these options will be applied to each upload request.
87+
*
88+
* @see Builder#setWriteOptsPerRequest(List)
89+
*/
7890
@BetaApi
7991
public @NonNull List<BlobWriteOption> getWriteOptsPerRequest() {
8092
return writeOptsPerRequest;
@@ -92,12 +104,12 @@ public boolean equals(Object o) {
92104
return skipIfExists == that.skipIfExists
93105
&& prefix.equals(that.prefix)
94106
&& bucketName.equals(that.bucketName)
95-
&& targetOptsPerRequest.equals(that.targetOptsPerRequest);
107+
&& writeOptsPerRequest.equals(that.writeOptsPerRequest);
96108
}
97109

98110
@Override
99111
public int hashCode() {
100-
return Objects.hash(skipIfExists, prefix, bucketName, targetOptsPerRequest);
112+
return Objects.hash(skipIfExists, prefix, bucketName, writeOptsPerRequest);
101113
}
102114

103115
@Override
@@ -106,7 +118,7 @@ public String toString() {
106118
.add("skipIfExists", skipIfExists)
107119
.add("prefix", prefix)
108120
.add("bucketName", bucketName)
109-
.add("optionsPerRequest", targetOptsPerRequest)
121+
.add("writeOptsPerRequest", writeOptsPerRequest)
110122
.toString();
111123
}
112124

@@ -124,61 +136,86 @@ private static List<BlobWriteOption> applySkipIfExists(
124136
return writeOptsPerRequest;
125137
}
126138

139+
/**
140+
* Builds an instance of ParallelUploadConfig.
141+
*
142+
* @see ParallelUploadConfig
143+
*/
127144
@BetaApi
128145
public static final class Builder {
129146

130147
private boolean skipIfExists;
131148
private @NonNull String prefix;
132149
private @NonNull String bucketName;
133-
private @NonNull List<BlobTargetOption> optionsPerRequest;
134-
135150
private @NonNull List<BlobWriteOption> writeOptsPerRequest;
136151

137152
private Builder() {
138153
this.prefix = "";
139154
this.bucketName = "";
140-
this.optionsPerRequest = ImmutableList.of();
141155
this.writeOptsPerRequest = ImmutableList.of();
142156
}
143157

158+
/**
159+
* Sets the parameter for skipIfExists. When set to true Transfer Manager will skip uploading an
160+
* object if it already exists.
161+
*
162+
* @return the builder instance with the value for skipIfExists modified.
163+
* @see ParallelUploadConfig#isSkipIfExists()
164+
*/
144165
@BetaApi
145166
public Builder setSkipIfExists(boolean skipIfExists) {
146167
this.skipIfExists = skipIfExists;
147168
return this;
148169
}
149170

171+
/**
172+
* Sets a common prefix that will be applied to all object paths in the destination bucket.
173+
*
174+
* @return the builder instance with the value for prefix modified.
175+
* @see ParallelUploadConfig#getPrefix()
176+
*/
150177
@BetaApi
151178
public Builder setPrefix(@NonNull String prefix) {
152179
this.prefix = prefix;
153180
return this;
154181
}
155182

183+
/**
184+
* Sets the bucketName that Transfer Manager will upload to. This field is required.
185+
*
186+
* @return the builder instance with the value for bucketName modified.
187+
* @see ParallelUploadConfig#getBucketName()
188+
*/
156189
@BetaApi
157190
public Builder setBucketName(@NonNull String bucketName) {
158191
this.bucketName = bucketName;
159192
return this;
160193
}
161194

162-
@BetaApi
163-
public Builder setOptionsPerRequest(@NonNull List<BlobTargetOption> optionsPerRequest) {
164-
this.optionsPerRequest = ImmutableList.copyOf(optionsPerRequest);
165-
return this;
166-
}
167-
195+
/**
196+
* Sets the BlobWriteOptions that will be applied to each upload request. Note these options
197+
* will be applied to every single upload request.
198+
*
199+
* @return the builder instance with the value for WriteOptsPerRequest modified.
200+
* @see ParallelUploadConfig#getWriteOptsPerRequest()
201+
*/
168202
@BetaApi
169203
public Builder setWriteOptsPerRequest(@NonNull List<BlobWriteOption> writeOptsPerRequest) {
170204
this.writeOptsPerRequest = writeOptsPerRequest;
171205
return this;
172206
}
173207

208+
/**
209+
* Creates a ParallelUploadConfig object.
210+
*
211+
* @return {@link ParallelUploadConfig}
212+
*/
174213
@BetaApi
175214
public ParallelUploadConfig build() {
176215
checkNotNull(prefix);
177216
checkNotNull(bucketName);
178-
checkNotNull(optionsPerRequest);
179217
checkNotNull(writeOptsPerRequest);
180-
return new ParallelUploadConfig(
181-
skipIfExists, prefix, bucketName, optionsPerRequest, writeOptsPerRequest);
218+
return new ParallelUploadConfig(skipIfExists, prefix, bucketName, writeOptsPerRequest);
182219
}
183220
}
184221
}

0 commit comments

Comments
 (0)