Skip to content

Commit 6d861cf

Browse files
committed
Lessen boilerplate.
1 parent 317a345 commit 6d861cf

File tree

348 files changed

+1053
-1163
lines changed

Some content is hidden

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

348 files changed

+1053
-1163
lines changed

azure/src/main/java/ch/cyberduck/core/azure/AzureDirectoryFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Path mkdir(final Path folder, final TransferStatus status) throws Backgro
7272
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
7373
type.add(Path.Type.placeholder);
7474
return new AzureTouchFeature(session, context).withWriter(writer).touch(folder.withType(type),
75-
status.withChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)));
75+
status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)));
7676
}
7777
}
7878
catch(URISyntaxException e) {

azure/src/main/java/ch/cyberduck/core/azure/AzureMoveFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void preflight(final Path source, final Optional<Path> target) throws Bac
4949

5050
@Override
5151
public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException {
52-
final Path copy = proxy.copy(file, renamed, new TransferStatus().withLength(file.attributes().getSize()), connectionCallback, new DisabledStreamListener());
52+
final Path copy = proxy.copy(file, renamed, new TransferStatus().setLength(file.attributes().getSize()), connectionCallback, new DisabledStreamListener());
5353
delete.delete(Collections.singletonList(file), connectionCallback, callback);
5454
return copy;
5555
}

azure/src/test/java/ch/cyberduck/core/azure/AzureCopyFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public void testCopyToExistingFile() throws Exception {
6060
final Path test = new AzureTouchFeature(session, null).touch(
6161
new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
6262
final byte[] content = RandomUtils.nextBytes(1023);
63-
final OutputStream out = new AzureWriteFeature(session, null).write(test, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
63+
final OutputStream out = new AzureWriteFeature(session, null).write(test, new TransferStatus().setLength(content.length), new DisabledConnectionCallback());
6464
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out);
6565
final Path copy = new AzureTouchFeature(session, null).touch(
6666
new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
67-
new AzureCopyFeature(session, null).copy(test, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener());
67+
new AzureCopyFeature(session, null).copy(test, copy, new TransferStatus().setExists(true), new DisabledConnectionCallback(), new DisabledStreamListener());
6868
assertEquals(1023L, new AzureAttributesFinderFeature(session, null).find(copy).getSize());
6969
final Find find = new DefaultFindFeature(session);
7070
assertTrue(find.find(test));

azure/src/test/java/ch/cyberduck/core/azure/AzureReadFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void testReadZeroLength() throws Exception {
3939
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
4040
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
4141
new AzureTouchFeature(session, null).touch(test, new TransferStatus());
42-
final InputStream in = new AzureReadFeature(session, null).read(test, new TransferStatus().withLength(0L), new DisabledConnectionCallback());
42+
final InputStream in = new AzureReadFeature(session, null).read(test, new TransferStatus().setLength(0L), new DisabledConnectionCallback());
4343
assertNotNull(in);
4444
in.close();
4545
new AzureDeleteFeature(session, null).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
@@ -51,7 +51,7 @@ public void testReadRange() throws Exception {
5151
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
5252
new AzureTouchFeature(session, null).touch(test, new TransferStatus());
5353
final byte[] content = RandomUtils.nextBytes(1023);
54-
final OutputStream out = new AzureWriteFeature(session, null).write(test, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
54+
final OutputStream out = new AzureWriteFeature(session, null).write(test, new TransferStatus().setLength(content.length), new DisabledConnectionCallback());
5555
assertNotNull(out);
5656
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out);
5757
final TransferStatus status = new TransferStatus();

azure/src/test/java/ch/cyberduck/core/azure/AzureWriteFeatureTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void testWriteOverrideAppendBlob() throws Exception {
4040
status.setMime("text/plain");
4141
final byte[] content = RandomUtils.nextBytes(513);
4242
status.setLength(content.length);
43-
status.setChecksum(new MD5ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus().withLength(content.length)));
43+
status.setChecksum(new MD5ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus().setLength(content.length)));
4444
status.setMetadata(Collections.singletonMap("Cache-Control", "public,max-age=86400"));
4545
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
4646
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
@@ -58,8 +58,8 @@ public void testWriteOverrideAppendBlob() throws Exception {
5858
IOUtils.readFully(in, buffer);
5959
in.close();
6060
assertArrayEquals(content, buffer);
61-
final OutputStream overwrite = new AzureWriteFeature(session, context).write(test, new TransferStatus().exists(true)
62-
.withLength("overwrite".getBytes(StandardCharsets.UTF_8).length).withMetadata(Collections.singletonMap("Content-Type", "text/plain")), new DisabledConnectionCallback());
61+
final OutputStream overwrite = new AzureWriteFeature(session, context).write(test, new TransferStatus().setExists(true)
62+
.setLength("overwrite".getBytes(StandardCharsets.UTF_8).length).setMetadata(Collections.singletonMap("Content-Type", "text/plain")), new DisabledConnectionCallback());
6363
new StreamCopier(new TransferStatus(), new TransferStatus())
6464
.transfer(new ByteArrayInputStream("overwrite".getBytes(StandardCharsets.UTF_8)), overwrite);
6565
overwrite.close();
@@ -77,7 +77,7 @@ public void testWriteOverrideBlockBlob() throws Exception {
7777
status.setMime("text/plain");
7878
final byte[] content = RandomUtils.nextBytes(513);
7979
status.setLength(content.length);
80-
status.setChecksum(new MD5ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus().withLength(content.length)));
80+
status.setChecksum(new MD5ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus().setLength(content.length)));
8181
status.setMetadata(Collections.singletonMap("Cache-Control", "public,max-age=86400"));
8282
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
8383
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
@@ -95,8 +95,8 @@ public void testWriteOverrideBlockBlob() throws Exception {
9595
IOUtils.readFully(in, buffer);
9696
in.close();
9797
assertArrayEquals(content, buffer);
98-
final OutputStream overwrite = new AzureWriteFeature(session, context).write(test, new TransferStatus().exists(true)
99-
.withLength("overwrite".getBytes(StandardCharsets.UTF_8).length).withMetadata(Collections.singletonMap("Content-Type", "text/plain")), new DisabledConnectionCallback());
98+
final OutputStream overwrite = new AzureWriteFeature(session, context).write(test, new TransferStatus().setExists(true)
99+
.setLength("overwrite".getBytes(StandardCharsets.UTF_8).length).setMetadata(Collections.singletonMap("Content-Type", "text/plain")), new DisabledConnectionCallback());
100100
new StreamCopier(new TransferStatus(), new TransferStatus())
101101
.transfer(new ByteArrayInputStream("overwrite".getBytes(StandardCharsets.UTF_8)), overwrite);
102102
overwrite.close();

azure/src/test/java/ch/cyberduck/core/cryptomator/AzureWriteFeatureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void testWrite() throws Exception {
8787
final PathAttributes attributes = new CryptoListService(session, new AzureListService(session, context), cryptomator).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes();
8888
assertEquals(content.length, attributes.getSize());
8989
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
90-
final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, context), cryptomator).read(test, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
90+
final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, context), cryptomator).read(test, new TransferStatus().setLength(content.length), new DisabledConnectionCallback());
9191
new StreamCopier(status, status).transfer(in, buffer);
9292
assertArrayEquals(content, buffer.toByteArray());
9393
cryptomator.getFeature(session, Delete.class, new AzureDeleteFeature(session, context)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());

azure/src/test/java/ch/cyberduck/core/cryptomator/CopyWorkerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ public void testCopyFile() throws Exception {
8282
final byte[] content = RandomUtils.nextBytes(40500);
8383
final TransferStatus status = new TransferStatus();
8484
new CryptoBulkFeature<>(session, new DisabledBulkFeature(), new AzureDeleteFeature(session, null), cryptomator).pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(source), status), new DisabledConnectionCallback());
85-
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), new CryptoWriteFeature<>(session, new AzureWriteFeature(session, null), cryptomator).write(source, status.withLength(content.length), new DisabledConnectionCallback()));
85+
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), new CryptoWriteFeature<>(session, new AzureWriteFeature(session, null), cryptomator).write(source, status.setLength(content.length), new DisabledConnectionCallback()));
8686
assertTrue(cryptomator.getFeature(session, Find.class, new DefaultFindFeature(session)).find(source));
8787
final CopyWorker worker = new CopyWorker(Collections.singletonMap(source, target), new SessionPool.SingleSessionPool(session, registry), PathCache.empty(), new DisabledProgressListener(), new DisabledConnectionCallback());
8888
worker.run(session);
8989
assertTrue(cryptomator.getFeature(session, Find.class, new AzureFindFeature(session, null)).find(source));
9090
assertTrue(cryptomator.getFeature(session, Find.class, new AzureFindFeature(session, null)).find(target));
9191
final ByteArrayOutputStream out = new ByteArrayOutputStream(content.length);
92-
assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback()), out));
92+
assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(target, new TransferStatus().setLength(content.length), new DisabledConnectionCallback()), out));
9393
assertArrayEquals(content, out.toByteArray());
9494
new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(vault), new DisabledProgressListener()).run(session);
9595
}
@@ -175,7 +175,7 @@ public void testCopyFileIntoVault() throws Exception {
175175
final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
176176
final Path cleartextFile = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
177177
final byte[] content = RandomUtils.nextBytes(40500);
178-
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), new AzureWriteFeature(session, null).write(cleartextFile, new TransferStatus().withLength(content.length), new DisabledConnectionCallback()));
178+
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), new AzureWriteFeature(session, null).write(cleartextFile, new TransferStatus().setLength(content.length), new DisabledConnectionCallback()));
179179
assertTrue(new AzureFindFeature(session, null).find(cleartextFile));
180180
final Path encryptedFolder = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
181181
final Path encryptedFile = new Path(encryptedFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
@@ -191,7 +191,7 @@ public void testCopyFileIntoVault() throws Exception {
191191
assertTrue(new AzureFindFeature(session, null).find(cleartextFile));
192192
assertTrue(cryptomator.getFeature(session, Find.class, new AzureFindFeature(session, null)).find(encryptedFile));
193193
final ByteArrayOutputStream out = new ByteArrayOutputStream(content.length);
194-
assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(encryptedFile, new TransferStatus().withLength(content.length), new DisabledConnectionCallback()), out));
194+
assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(encryptedFile, new TransferStatus().setLength(content.length), new DisabledConnectionCallback()), out));
195195
assertArrayEquals(content, out.toByteArray());
196196
registry.clear();
197197
new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(vault), new DisabledProgressListener()).run(session);

azure/src/test/java/ch/cyberduck/core/cryptomator/CryptoAzureSingleTransferWorkerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ public TransferAction prompt(final TransferItem file) {
106106
assertEquals(content.length, cryptomator.getFeature(session, AttributesFinder.class, new AzureAttributesFinderFeature(session, null)).find(file1).getSize());
107107
{
108108
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
109-
final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
109+
final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(file1, new TransferStatus().setLength(content.length), new DisabledConnectionCallback());
110110
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
111111
assertArrayEquals(content, buffer.toByteArray());
112112
}
113113
assertEquals(content.length, cryptomator.getFeature(session, AttributesFinder.class, new AzureAttributesFinderFeature(session, null)).find(file2).getSize());
114114
{
115115
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
116-
final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
116+
final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(file1, new TransferStatus().setLength(content.length), new DisabledConnectionCallback());
117117
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
118118
assertArrayEquals(content, buffer.toByteArray());
119119
}

azure/src/test/java/ch/cyberduck/core/worker/AzureSingleTransferWorkerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ public void testDownload() throws Exception {
6666
final Local localFile = TemporaryFileServiceFactory.get().create(test.getName());
6767
{
6868
final byte[] content = RandomUtils.nextBytes(39864);
69-
final TransferStatus writeStatus = new TransferStatus().withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
69+
final TransferStatus writeStatus = new TransferStatus().setLength(content.length).setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
7070
final StatusOutputStream out = new AzureWriteFeature(session, null).write(test, writeStatus, new DisabledConnectionCallback());
7171
assertNotNull(out);
7272
new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
7373
out.close();
7474
}
7575
final byte[] content = RandomUtils.nextBytes(39864);
76-
final TransferStatus writeStatus = new TransferStatus().withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
76+
final TransferStatus writeStatus = new TransferStatus().setLength(content.length).setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
7777
final StatusOutputStream<Void> out = new AzureWriteFeature(session, null).write(test, writeStatus, new DisabledConnectionCallback());
7878
assertNotNull(out);
7979
new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);

backblaze/src/main/java/ch/cyberduck/core/b2/B2DirectoryFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public Path mkdir(final Path folder, final TransferStatus status) throws Backgro
7272
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
7373
type.add(Path.Type.placeholder);
7474
return new B2TouchFeature(session, fileid).touch(folder.withType(type), status
75-
.withMime(MimeTypeService.DEFAULT_CONTENT_TYPE)
76-
.withChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)));
75+
.setMime(MimeTypeService.DEFAULT_CONTENT_TYPE)
76+
.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status)));
7777
}
7878
}
7979
catch(B2ApiException e) {

0 commit comments

Comments
 (0)