1818package org .apache .hadoop .ozone .om .helpers ;
1919
2020import com .google .common .annotations .VisibleForTesting ;
21+ import com .google .common .collect .ImmutableList ;
2122import jakarta .annotation .Nonnull ;
2223import java .util .ArrayList ;
2324import java .util .HashMap ;
@@ -48,7 +49,7 @@ public final class OmKeyArgs implements Auditable {
4849 private final int multipartUploadPartNumber ;
4950 private final Map <String , String > metadata ;
5051 private final boolean sortDatanodesInPipeline ;
51- private final List <OzoneAcl > acls ;
52+ private final ImmutableList <OzoneAcl > acls ;
5253 private final boolean latestVersionLocation ;
5354 private final boolean recursive ;
5455 private final boolean headOp ;
@@ -73,7 +74,7 @@ private OmKeyArgs(Builder b) {
7374 this .multipartUploadID = b .multipartUploadID ;
7475 this .multipartUploadPartNumber = b .multipartUploadPartNumber ;
7576 this .metadata = b .metadata ;
76- this .acls = b .acls ;
77+ this .acls = b .acls . build () ;
7778 this .sortDatanodesInPipeline = b .sortDatanodesInPipeline ;
7879 this .latestVersionLocation = b .latestVersionLocation ;
7980 this .recursive = b .recursive ;
@@ -191,30 +192,7 @@ public void addLocationInfo(OmKeyLocationInfo locationInfo) {
191192 }
192193
193194 public OmKeyArgs .Builder toBuilder () {
194- OmKeyArgs .Builder builder = new OmKeyArgs .Builder ()
195- .setVolumeName (volumeName )
196- .setBucketName (bucketName )
197- .setKeyName (keyName )
198- .setOwnerName (ownerName )
199- .setDataSize (dataSize )
200- .setReplicationConfig (replicationConfig )
201- .setLocationInfoList (locationInfoList )
202- .setIsMultipartKey (isMultipartKey )
203- .setMultipartUploadID (multipartUploadID )
204- .setMultipartUploadPartNumber (multipartUploadPartNumber )
205- .addAllMetadata (metadata )
206- .setSortDatanodesInPipeline (sortDatanodesInPipeline )
207- .setHeadOp (headOp )
208- .setLatestVersionLocation (latestVersionLocation )
209- .setAcls (acls )
210- .setForceUpdateContainerCacheFromSCM (forceUpdateContainerCacheFromSCM )
211- .addAllTags (tags );
212-
213- if (expectedDataGeneration != null ) {
214- builder .setExpectedDataGeneration (expectedDataGeneration );
215- }
216-
217- return builder ;
195+ return new Builder (this );
218196 }
219197
220198 @ Nonnull
@@ -256,13 +234,44 @@ public static class Builder {
256234 private final Map <String , String > metadata = new HashMap <>();
257235 private boolean sortDatanodesInPipeline ;
258236 private boolean latestVersionLocation ;
259- private List < OzoneAcl > acls ;
237+ private final AclListBuilder acls ;
260238 private boolean recursive ;
261239 private boolean headOp ;
262240 private boolean forceUpdateContainerCacheFromSCM ;
263241 private final Map <String , String > tags = new HashMap <>();
264242 private Long expectedDataGeneration = null ;
265243
244+ public Builder () {
245+ this (AclListBuilder .empty ());
246+ }
247+
248+ private Builder (AclListBuilder acls ) {
249+ this .acls = acls ;
250+ }
251+
252+ public Builder (OmKeyArgs obj ) {
253+ this .volumeName = obj .volumeName ;
254+ this .bucketName = obj .bucketName ;
255+ this .keyName = obj .keyName ;
256+ this .ownerName = obj .ownerName ;
257+ this .dataSize = obj .dataSize ;
258+ this .replicationConfig = obj .replicationConfig ;
259+ this .locationInfoList = obj .locationInfoList ;
260+ this .isMultipartKey = obj .isMultipartKey ;
261+ this .multipartUploadID = obj .multipartUploadID ;
262+ this .multipartUploadPartNumber = obj .multipartUploadPartNumber ;
263+ this .sortDatanodesInPipeline = obj .sortDatanodesInPipeline ;
264+ this .latestVersionLocation = obj .latestVersionLocation ;
265+ this .recursive = obj .recursive ;
266+ this .headOp = obj .headOp ;
267+ this .forceUpdateContainerCacheFromSCM =
268+ obj .forceUpdateContainerCacheFromSCM ;
269+ this .expectedDataGeneration = obj .expectedDataGeneration ;
270+ this .metadata .putAll (obj .metadata );
271+ this .tags .putAll (obj .tags );
272+ this .acls = AclListBuilder .of (obj .acls );
273+ }
274+
266275 public Builder setVolumeName (String volume ) {
267276 this .volumeName = volume ;
268277 return this ;
@@ -299,7 +308,7 @@ public Builder setLocationInfoList(List<OmKeyLocationInfo> locationInfos) {
299308 }
300309
301310 public Builder setAcls (List <OzoneAcl > listOfAcls ) {
302- this .acls = listOfAcls ;
311+ this .acls . addAll ( listOfAcls ) ;
303312 return this ;
304313 }
305314
0 commit comments