Skip to content

Commit fdfc47f

Browse files
committed
Refactor messages by subclasses
merge SelectObjectContentRequest merge ListVersionsResult Remove unused CompleteMultipartUploadOutput.java merge ListMultipartUploadsResult merge NotificationRecords merge SseConfiguration merge DeleteRequest, DeleteResult merge RestoreRequest merge NotificationConfiguration merge LifecycleConfiguration merge ReplicationConfiguration merge Filter merge ObjectLockConfiguration merge ListAllMyBucketsResult merge Item merge ListObjectsResult Move common fields for ListPartsResult and GetObjectAttributesOutput Signed-off-by: Bala.FA <[email protected]>
1 parent 5e7e074 commit fdfc47f

File tree

225 files changed

+10280
-9677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+10280
-9677
lines changed

adminapi/src/main/java/io/minio/admin/MinioAdminClient.java

+53-55
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2025 MinIO, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.minio;
18+
19+
import java.util.Objects;
20+
21+
/**
22+
* Argument class of {@link MinioAsyncClient#abortMultipartUpload} and {@link
23+
* MinioClient#abortMultipartUpload}.
24+
*/
25+
public class AbortMultipartUploadArgs extends ObjectArgs {
26+
private String uploadId;
27+
28+
public String uploadId() {
29+
return uploadId;
30+
}
31+
32+
public static Builder builder() {
33+
return new Builder();
34+
}
35+
36+
/** Argument builder of {@link AbortMultipartUploadArgs}. */
37+
public static final class Builder extends ObjectArgs.Builder<Builder, AbortMultipartUploadArgs> {
38+
@Override
39+
protected void validate(AbortMultipartUploadArgs args) {
40+
super.validate(args);
41+
Utils.validateNotEmptyString(args.uploadId, "upload ID");
42+
}
43+
44+
public Builder uploadId(String uploadId) {
45+
Utils.validateNotEmptyString(uploadId, "upload ID");
46+
operations.add(args -> args.uploadId = uploadId);
47+
return this;
48+
}
49+
}
50+
51+
@Override
52+
public boolean equals(Object o) {
53+
if (this == o) return true;
54+
if (!(o instanceof AbortMultipartUploadArgs)) return false;
55+
if (!super.equals(o)) return false;
56+
AbortMultipartUploadArgs that = (AbortMultipartUploadArgs) o;
57+
return Objects.equals(uploadId, that.uploadId);
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return Objects.hash(super.hashCode(), uploadId);
63+
}
64+
}

api/src/main/java/io/minio/BaseArgs.java

+15-47
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@
3030

3131
/** Base argument class. */
3232
public abstract class BaseArgs {
33+
private String location;
3334
protected Multimap<String, String> extraHeaders =
3435
Multimaps.unmodifiableMultimap(HashMultimap.create());
3536
protected Multimap<String, String> extraQueryParams =
3637
Multimaps.unmodifiableMultimap(HashMultimap.create());
3738

39+
public void setLocation(String location) {
40+
this.location = location;
41+
}
42+
43+
public String location() {
44+
return location;
45+
}
46+
3847
public Multimap<String, String> extraHeaders() {
3948
return extraHeaders;
4049
}
@@ -43,12 +52,12 @@ public Multimap<String, String> extraQueryParams() {
4352
return extraQueryParams;
4453
}
4554

46-
protected void checkSse(ServerSideEncryption sse, HttpUrl url) {
55+
protected void checkSse(ServerSideEncryption sse, boolean isHttps) {
4756
if (sse == null) {
4857
return;
4958
}
5059

51-
if (sse.tlsRequired() && !url.isHttps()) {
60+
if (sse.tlsRequired() && !isHttps) {
5261
throw new IllegalArgumentException(
5362
sse + " operations must be performed over a secure connection.");
5463
}
@@ -60,75 +69,34 @@ public abstract static class Builder<B extends Builder<B, A>, A extends BaseArgs
6069

6170
protected abstract void validate(A args);
6271

63-
protected void validateNotNull(Object arg, String argName) {
64-
if (arg == null) {
65-
throw new IllegalArgumentException(argName + " must not be null.");
66-
}
67-
}
68-
69-
protected void validateNotEmptyString(String arg, String argName) {
70-
validateNotNull(arg, argName);
71-
if (arg.isEmpty()) {
72-
throw new IllegalArgumentException(argName + " must be a non-empty string.");
73-
}
74-
}
75-
76-
protected void validateNullOrNotEmptyString(String arg, String argName) {
77-
if (arg != null && arg.isEmpty()) {
78-
throw new IllegalArgumentException(argName + " must be a non-empty string.");
79-
}
80-
}
81-
82-
protected void validateNullOrPositive(Number arg, String argName) {
83-
if (arg != null && arg.longValue() < 0) {
84-
throw new IllegalArgumentException(argName + " cannot be non-negative.");
85-
}
86-
}
87-
8872
public Builder() {
8973
this.operations = new ArrayList<>();
9074
}
9175

92-
protected Multimap<String, String> copyMultimap(Multimap<String, String> multimap) {
93-
Multimap<String, String> multimapCopy = HashMultimap.create();
94-
if (multimap != null) {
95-
multimapCopy.putAll(multimap);
96-
}
97-
return Multimaps.unmodifiableMultimap(multimapCopy);
98-
}
99-
100-
protected Multimap<String, String> toMultimap(Map<String, String> map) {
101-
Multimap<String, String> multimap = HashMultimap.create();
102-
if (map != null) {
103-
multimap.putAll(Multimaps.forMap(map));
104-
}
105-
return Multimaps.unmodifiableMultimap(multimap);
106-
}
107-
10876
@SuppressWarnings("unchecked") // Its safe to type cast to B as B extends this class.
10977
public B extraHeaders(Multimap<String, String> headers) {
110-
final Multimap<String, String> extraHeaders = copyMultimap(headers);
78+
final Multimap<String, String> extraHeaders = Utils.newMultimap(headers);
11179
operations.add(args -> args.extraHeaders = extraHeaders);
11280
return (B) this;
11381
}
11482

11583
@SuppressWarnings("unchecked") // Its safe to type cast to B as B extends this class.
11684
public B extraQueryParams(Multimap<String, String> queryParams) {
117-
final Multimap<String, String> extraQueryParams = copyMultimap(queryParams);
85+
final Multimap<String, String> extraQueryParams = Utils.newMultimap(queryParams);
11886
operations.add(args -> args.extraQueryParams = extraQueryParams);
11987
return (B) this;
12088
}
12189

12290
@SuppressWarnings("unchecked") // Its safe to type cast to B as B extends this class.
12391
public B extraHeaders(Map<String, String> headers) {
124-
final Multimap<String, String> extraHeaders = toMultimap(headers);
92+
final Multimap<String, String> extraHeaders = Utils.newMultimap(headers);
12593
operations.add(args -> args.extraHeaders = extraHeaders);
12694
return (B) this;
12795
}
12896

12997
@SuppressWarnings("unchecked") // Its safe to type cast to B as B extends this class.
13098
public B extraQueryParams(Map<String, String> queryParams) {
131-
final Multimap<String, String> extraQueryParams = toMultimap(queryParams);
99+
final Multimap<String, String> extraQueryParams = Utils.newMultimap(queryParams);
132100
operations.add(args -> args.extraQueryParams = extraQueryParams);
133101
return (B) this;
134102
}

0 commit comments

Comments
 (0)