Skip to content

Commit 677d3d0

Browse files
committed
Lessen boilerplate.
1 parent 6d861cf commit 677d3d0

File tree

29 files changed

+47
-52
lines changed

29 files changed

+47
-52
lines changed

core/src/main/java/ch/cyberduck/core/PathAttributes.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,6 @@ public PathAttributes setFileId(final String fileId) {
473473
return this;
474474
}
475475

476-
public PathAttributes withFileId(final String fileId) {
477-
this.setFileId(fileId);
478-
return this;
479-
}
480-
481476
public String getLockId() {
482477
return lockId;
483478
}

core/src/test/java/ch/cyberduck/core/DefaultPathPredicateTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public void testPredicateVersionIdFile() {
8484

8585
@Test
8686
public void testPredicateFileIdFile() {
87-
final Path t = new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().withFileId("1"));
87+
final Path t = new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().setFileId("1"));
8888
assertTrue(new DefaultPathPredicate(t).test(t));
89-
assertTrue(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().withFileId("1"))));
90-
assertFalse(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().withFileId("2"))));
89+
assertTrue(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().setFileId("1"))));
90+
assertFalse(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.file), new PathAttributes().setFileId("2"))));
9191
}
9292

9393
@Test
@@ -100,10 +100,10 @@ public void testPredicateVersionIdDirectory() {
100100

101101
@Test
102102
public void testPredicateFileIdDirectory() {
103-
final Path t = new Path("/f", EnumSet.of(Path.Type.directory), new PathAttributes().withFileId("1"));
103+
final Path t = new Path("/f", EnumSet.of(Path.Type.directory), new PathAttributes().setFileId("1"));
104104
assertTrue(new DefaultPathPredicate(t).test(t));
105-
assertTrue(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.directory), new PathAttributes().withFileId("1"))));
106-
assertFalse(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.directory), new PathAttributes().withFileId("2"))));
105+
assertTrue(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.directory), new PathAttributes().setFileId("1"))));
106+
assertFalse(new DefaultPathPredicate(t).test(new Path("/f", EnumSet.of(Path.Type.directory), new PathAttributes().setFileId("2"))));
107107
}
108108

109109
@Test

core/src/test/java/ch/cyberduck/core/PathCacheTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testDisabledCache() {
6969
@Test
7070
public void testDirectoryWithFileIdDefaultPredicate() {
7171
final PathCache cache = new PathCache(1);
72-
final Path f = new Path("/", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withFileId("1"));
72+
final Path f = new Path("/", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().setFileId("1"));
7373
assertFalse(cache.containsKey(f));
7474
cache.put(f, new AttributedList<>());
7575
assertTrue(cache.containsKey(f));
@@ -86,7 +86,7 @@ public CacheReference<Path> reference(final Path file) {
8686
return new SimplePathPredicate(file);
8787
}
8888
};
89-
final Path f = new Path("/", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withFileId("1"));
89+
final Path f = new Path("/", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().setFileId("1"));
9090
assertFalse(cache.containsKey(f));
9191
cache.put(f, new AttributedList<>());
9292
assertTrue(cache.containsKey(f));

core/src/test/java/ch/cyberduck/core/shared/ListFilteringFeatureTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ public void testSearch() {
4646
assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().setVersionId("v1"))).test(
4747
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().setVersionId("v2"))
4848
));
49-
assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v1"))).test(
50-
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v1"))
49+
assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().setFileId("v1"))).test(
50+
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().setFileId("v1"))
5151
));
52-
assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v1"))).test(
53-
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v2"))
52+
assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().setFileId("v1"))).test(
53+
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().setFileId("v2"))
5454
));
55-
assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withFileId("v1"))).test(
56-
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withFileId("v2"))
55+
assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().setFileId("v1"))).test(
56+
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().setFileId("v2"))
5757
));
5858
assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
5959
new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().setVersionId("v1"))

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/impl/CryptoDirectoryV6Provider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public Path toEncrypted(final Session<?> session, final String directoryId, fina
8181
final PathAttributes attributes = new PathAttributes(directory.attributes());
8282
// The root of the vault is a different target directory and file ids always correspond to the metadata file
8383
attributes.setVersionId(null);
84-
attributes.withFileId(null);
84+
attributes.setFileId(null);
8585
// Remember random directory id for use in vault
8686
final String id = this.toDirectoryId(session, directory, directoryId);
8787
log.debug("Use directory ID '{}' for folder {}", id, directory);

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxAttributesFinderFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ else if(containerService.isFourthLevel(file)) {
146146
final String boxNodeId = fileid.getBoxNodeId(file);
147147
// map BoxAccessPolicy to CANLISTCHILDREN and CANADDCHILDREN for third level
148148
final Box box = new BoxRestControllerApi(session.getClient()).getBox(deepBoxNodeId, boxNodeId);
149-
final PathAttributes attr = new PathAttributes().withFileId(fileId);
149+
final PathAttributes attr = new PathAttributes().setFileId(fileId);
150150
final Acl acl = new Acl(new Acl.CanonicalUser());
151151
final BoxAccessPolicy boxPolicy = box.getBoxPolicy();
152152
if(containerService.isInbox(file)) {

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxIdProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected Path normalize(final Path file) {
135135
return file;
136136
}
137137
}
138-
final Path deepbox = new Path(result, deepboxName, type, new PathAttributes(combined.attributes()).withFileId(null));
138+
final Path deepbox = new Path(result, deepboxName, type, new PathAttributes(combined.attributes()).setFileId(null));
139139
result = new Path(deepbox, boxName, type, segment.attributes());
140140
}
141141
else {

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxListService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
353353
list.add(new Path(directory,
354354
String.format("%s (%s)", DeepboxPathNormalizer.name(box.getCompany().getDisplayName()), DeepboxPathNormalizer.name(box.getBoxName())),
355355
EnumSet.of(Path.Type.directory, Path.Type.volume),
356-
new PathAttributes().withFileId(box.getBoxNodeId()).setCustom(DeepboxIdProvider.DEEPBOX_NAME_PROEPRTY_KEY, box.getDeepBoxName()))
356+
new PathAttributes().setFileId(box.getBoxNodeId()).setCustom(DeepboxIdProvider.DEEPBOX_NAME_PROEPRTY_KEY, box.getDeepBoxName()))
357357
);
358358
}
359359
// Mark duplicates

deepbox/src/main/java/ch/cyberduck/core/deepbox/DeepboxMoveFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu
7474
}
7575
fileid.cache(file, null);
7676
fileid.cache(renamed, sourceId);
77-
return new Path(renamed).withAttributes(new PathAttributes(file.attributes()).withFileId(sourceId));
77+
return new Path(renamed).withAttributes(new PathAttributes(file.attributes()).setFileId(sourceId));
7878
}
7979
catch(ApiException e) {
8080
throw new DeepboxExceptionMappingService(fileid).map("Cannot rename {0}", e, file);

dropbox/src/main/java/ch/cyberduck/core/dropbox/DropboxAttributesFinderFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public PathAttributes find(final Path file, final ListProgressListener listener)
5656
// Retrieve the namespace ID for a users home folder and team root folder
5757
final FullAccount account = new DbxUserUsersRequests(session.getClient()).getCurrentAccount();
5858
log.debug("Set root namespace {}", account.getRootInfo().getRootNamespaceId());
59-
return new PathAttributes().withFileId(account.getRootInfo().getRootNamespaceId());
59+
return new PathAttributes().setFileId(account.getRootInfo().getRootNamespaceId());
6060
}
6161
final Metadata metadata = new DbxUserFilesRequests(session.getClient(file)).getMetadata(containerService.getKey(file));
6262
if(metadata instanceof FileMetadata) {

0 commit comments

Comments
 (0)