From 0442f72d07b4d0d07d2f42ae3ac0ca845fd1daa5 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:31:53 +0100 Subject: [PATCH 1/2] Made "Cloud#type" non-nullable --- .../java/org/cryptomator/data/cloud/crypto/CryptoCloud.java | 2 ++ domain/src/main/java/org/cryptomator/domain/Cloud.kt | 2 +- domain/src/main/java/org/cryptomator/domain/DropboxCloud.java | 1 + .../src/main/java/org/cryptomator/domain/GoogleDriveCloud.java | 1 + .../main/java/org/cryptomator/domain/LocalStorageCloud.java | 1 + domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java | 1 + domain/src/main/java/org/cryptomator/domain/PCloud.java | 1 + domain/src/main/java/org/cryptomator/domain/S3Cloud.java | 1 + domain/src/main/java/org/cryptomator/domain/WebDavCloud.java | 1 + .../cryptomator/presentation/model/mappers/CloudModelMapper.kt | 3 +-- 10 files changed, 11 insertions(+), 3 deletions(-) diff --git a/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java b/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java index 65a843d33..ac62e7f1f 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java +++ b/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java @@ -3,6 +3,7 @@ import org.cryptomator.domain.Cloud; import org.cryptomator.domain.CloudType; import org.cryptomator.domain.Vault; +import org.jetbrains.annotations.NotNull; public class CryptoCloud implements Cloud { @@ -17,6 +18,7 @@ public Long id() { return null; } + @NotNull @Override public CloudType type() { return CloudType.CRYPTO; diff --git a/domain/src/main/java/org/cryptomator/domain/Cloud.kt b/domain/src/main/java/org/cryptomator/domain/Cloud.kt index 30496875b..0b8a53228 100644 --- a/domain/src/main/java/org/cryptomator/domain/Cloud.kt +++ b/domain/src/main/java/org/cryptomator/domain/Cloud.kt @@ -5,7 +5,7 @@ import java.io.Serializable interface Cloud : Serializable { fun id(): Long? - fun type(): CloudType? + fun type(): CloudType fun configurationMatches(cloud: Cloud?): Boolean fun persistent(): Boolean fun requiresNetwork(): Boolean diff --git a/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java b/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java index db70d609e..448429031 100644 --- a/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java @@ -38,6 +38,7 @@ public String username() { return username; } + @NotNull @Override public CloudType type() { return CloudType.DROPBOX; diff --git a/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java b/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java index cb1b13ab5..68ad9017b 100644 --- a/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java @@ -30,6 +30,7 @@ public Long id() { return id; } + @NotNull @Override public CloudType type() { return CloudType.GOOGLE_DRIVE; diff --git a/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java b/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java index 6915a6e0a..57b2dd209 100644 --- a/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java @@ -32,6 +32,7 @@ public String rootUri() { return rootUri; } + @NotNull @Override public CloudType type() { return CloudType.LOCAL; diff --git a/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java b/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java index 389e4611c..530d0eb77 100644 --- a/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java @@ -38,6 +38,7 @@ public String username() { return username; } + @NotNull @Override public CloudType type() { return CloudType.ONEDRIVE; diff --git a/domain/src/main/java/org/cryptomator/domain/PCloud.java b/domain/src/main/java/org/cryptomator/domain/PCloud.java index 163da1e96..b0e8e60e1 100644 --- a/domain/src/main/java/org/cryptomator/domain/PCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/PCloud.java @@ -45,6 +45,7 @@ public String username() { return username; } + @NotNull @Override public CloudType type() { return CloudType.PCLOUD; diff --git a/domain/src/main/java/org/cryptomator/domain/S3Cloud.java b/domain/src/main/java/org/cryptomator/domain/S3Cloud.java index ebc3c858b..b92c68fb6 100644 --- a/domain/src/main/java/org/cryptomator/domain/S3Cloud.java +++ b/domain/src/main/java/org/cryptomator/domain/S3Cloud.java @@ -66,6 +66,7 @@ public String displayName() { return displayName; } + @NotNull @Override public CloudType type() { return CloudType.S3; diff --git a/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java b/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java index 73f1f3d99..bedf399a3 100644 --- a/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java @@ -45,6 +45,7 @@ private boolean configurationMatches(WebDavCloud cloud) { return url.equals(cloud.url) && username.equals(cloud.username); } + @NotNull @Override public CloudType type() { return CloudType.WEBDAV; diff --git a/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt b/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt index 0006b4571..48a09a13e 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt @@ -22,7 +22,7 @@ class CloudModelMapper @Inject constructor() : ModelMapper() } override fun toModel(domainObject: Cloud): CloudModel { - return when (domainObject.type()?.let { CloudTypeModel.valueOf(it) }) { + return when (domainObject.type().let { CloudTypeModel.valueOf(it) }) { CloudTypeModel.DROPBOX -> DropboxCloudModel(domainObject) CloudTypeModel.GOOGLE_DRIVE -> GoogleDriveCloudModel(domainObject) CloudTypeModel.LOCAL -> LocalStorageModel(domainObject) @@ -31,7 +31,6 @@ class CloudModelMapper @Inject constructor() : ModelMapper() CloudTypeModel.S3 -> S3CloudModel(domainObject) CloudTypeModel.CRYPTO -> CryptoCloudModel(domainObject) CloudTypeModel.WEBDAV -> WebDavCloudModel(domainObject) - null -> throw IllegalStateException("The type of the object shouldn't be null") } } } From 163deacc9eba43b9aede596a2b29cc94f6724b1c Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:06:34 +0100 Subject: [PATCH 2/2] Turned "Cloud#type" into property --- .../dropbox/DropboxCloudContentRepositoryFactory.java | 2 +- .../onedrive/OnedriveCloudContentRepositoryFactory.java | 2 +- .../data/cloud/pcloud/PCloudContentRepositoryFactory.java | 2 +- .../GoogleDriveCloudContentRepositoryFactory.java | 2 +- .../org/cryptomator/data/cloud/crypto/CryptoCloud.java | 2 +- .../cloud/crypto/CryptoCloudContentRepositoryFactory.java | 2 +- .../cloud/local/LocalStorageContentRepositoryFactory.java | 2 +- .../data/cloud/s3/S3CloudContentRepositoryFactory.java | 2 +- .../cloud/webdav/WebDavCloudContentRepositoryFactory.java | 2 +- .../cryptomator/data/db/mappers/CloudEntityMapper.java | 6 +++--- .../cryptomator/data/repository/CloudRepositoryImpl.java | 2 +- .../data/cloud/crypto/MasterkeyCryptoCloudProviderTest.kt | 8 ++++---- domain/src/main/java/org/cryptomator/domain/Cloud.kt | 2 +- .../main/java/org/cryptomator/domain/DropboxCloud.java | 2 +- .../java/org/cryptomator/domain/GoogleDriveCloud.java | 2 +- .../java/org/cryptomator/domain/LocalStorageCloud.java | 2 +- .../main/java/org/cryptomator/domain/OnedriveCloud.java | 2 +- domain/src/main/java/org/cryptomator/domain/PCloud.java | 2 +- domain/src/main/java/org/cryptomator/domain/S3Cloud.java | 2 +- domain/src/main/java/org/cryptomator/domain/Vault.java | 6 +++--- .../src/main/java/org/cryptomator/domain/WebDavCloud.java | 2 +- .../domain/usecases/cloud/AddOrChangeCloudConnection.java | 2 +- .../cryptomator/domain/usecases/cloud/LogoutCloud.java | 2 +- .../cryptomator/presentation/model/CloudFolderModel.kt | 2 +- .../presentation/model/mappers/CloudModelMapper.kt | 2 +- .../presentation/presenter/AuthenticateCloudPresenter.kt | 6 +++--- 26 files changed, 35 insertions(+), 35 deletions(-) diff --git a/data/src/apiKey/java/org/cryptomator/data/cloud/dropbox/DropboxCloudContentRepositoryFactory.java b/data/src/apiKey/java/org/cryptomator/data/cloud/dropbox/DropboxCloudContentRepositoryFactory.java index c2abd0f69..6b2524ba6 100644 --- a/data/src/apiKey/java/org/cryptomator/data/cloud/dropbox/DropboxCloudContentRepositoryFactory.java +++ b/data/src/apiKey/java/org/cryptomator/data/cloud/dropbox/DropboxCloudContentRepositoryFactory.java @@ -24,7 +24,7 @@ public DropboxCloudContentRepositoryFactory(Context context) { @Override public boolean supports(Cloud cloud) { - return cloud.type() == DROPBOX; + return cloud.getType() == DROPBOX; } @Override diff --git a/data/src/apiKey/java/org/cryptomator/data/cloud/onedrive/OnedriveCloudContentRepositoryFactory.java b/data/src/apiKey/java/org/cryptomator/data/cloud/onedrive/OnedriveCloudContentRepositoryFactory.java index 148d4d646..c824f211a 100644 --- a/data/src/apiKey/java/org/cryptomator/data/cloud/onedrive/OnedriveCloudContentRepositoryFactory.java +++ b/data/src/apiKey/java/org/cryptomator/data/cloud/onedrive/OnedriveCloudContentRepositoryFactory.java @@ -24,7 +24,7 @@ public OnedriveCloudContentRepositoryFactory(Context context) { @Override public boolean supports(Cloud cloud) { - return cloud.type() == ONEDRIVE; + return cloud.getType() == ONEDRIVE; } @Override diff --git a/data/src/apiKey/java/org/cryptomator/data/cloud/pcloud/PCloudContentRepositoryFactory.java b/data/src/apiKey/java/org/cryptomator/data/cloud/pcloud/PCloudContentRepositoryFactory.java index ad64e0653..c79a04713 100644 --- a/data/src/apiKey/java/org/cryptomator/data/cloud/pcloud/PCloudContentRepositoryFactory.java +++ b/data/src/apiKey/java/org/cryptomator/data/cloud/pcloud/PCloudContentRepositoryFactory.java @@ -24,7 +24,7 @@ public PCloudContentRepositoryFactory(Context context) { @Override public boolean supports(Cloud cloud) { - return cloud.type() == PCLOUD; + return cloud.getType() == PCLOUD; } @Override diff --git a/data/src/apkStorePlaystore/java/org/cryptomator/data/cloud/googledrive/GoogleDriveCloudContentRepositoryFactory.java b/data/src/apkStorePlaystore/java/org/cryptomator/data/cloud/googledrive/GoogleDriveCloudContentRepositoryFactory.java index ff831344b..a79d0cf9a 100644 --- a/data/src/apkStorePlaystore/java/org/cryptomator/data/cloud/googledrive/GoogleDriveCloudContentRepositoryFactory.java +++ b/data/src/apkStorePlaystore/java/org/cryptomator/data/cloud/googledrive/GoogleDriveCloudContentRepositoryFactory.java @@ -25,7 +25,7 @@ public GoogleDriveCloudContentRepositoryFactory(Context context, GoogleDriveIdCa @Override public boolean supports(Cloud cloud) { - return cloud.type() == CloudType.GOOGLE_DRIVE; + return cloud.getType() == CloudType.GOOGLE_DRIVE; } @Override diff --git a/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java b/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java index ac62e7f1f..edcb48564 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java +++ b/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloud.java @@ -20,7 +20,7 @@ public Long id() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.CRYPTO; } diff --git a/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloudContentRepositoryFactory.java b/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloudContentRepositoryFactory.java index 87ff7d316..70b2b9238 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloudContentRepositoryFactory.java +++ b/data/src/main/java/org/cryptomator/data/cloud/crypto/CryptoCloudContentRepositoryFactory.java @@ -35,7 +35,7 @@ public CryptoCloudContentRepositoryFactory(Lazy cloudCon @Override public boolean supports(Cloud cloud) { - return cloud.type() == CRYPTO; + return cloud.getType() == CRYPTO; } @Override diff --git a/data/src/main/java/org/cryptomator/data/cloud/local/LocalStorageContentRepositoryFactory.java b/data/src/main/java/org/cryptomator/data/cloud/local/LocalStorageContentRepositoryFactory.java index 97c4b18ef..229c486f3 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/local/LocalStorageContentRepositoryFactory.java +++ b/data/src/main/java/org/cryptomator/data/cloud/local/LocalStorageContentRepositoryFactory.java @@ -31,7 +31,7 @@ public LocalStorageContentRepositoryFactory(Context context, MimeTypes mimeTypes @Override public boolean supports(Cloud cloud) { - return cloud.type() == LOCAL; + return cloud.getType() == LOCAL; } @Override diff --git a/data/src/main/java/org/cryptomator/data/cloud/s3/S3CloudContentRepositoryFactory.java b/data/src/main/java/org/cryptomator/data/cloud/s3/S3CloudContentRepositoryFactory.java index 6c41e2702..2a2f3beb1 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/s3/S3CloudContentRepositoryFactory.java +++ b/data/src/main/java/org/cryptomator/data/cloud/s3/S3CloudContentRepositoryFactory.java @@ -27,7 +27,7 @@ public S3CloudContentRepositoryFactory(Context context, SharedPreferencesHandler @Override public boolean supports(Cloud cloud) { - return cloud.type() == S3; + return cloud.getType() == S3; } @Override diff --git a/data/src/main/java/org/cryptomator/data/cloud/webdav/WebDavCloudContentRepositoryFactory.java b/data/src/main/java/org/cryptomator/data/cloud/webdav/WebDavCloudContentRepositoryFactory.java index 9231e8289..a8fae7e00 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/webdav/WebDavCloudContentRepositoryFactory.java +++ b/data/src/main/java/org/cryptomator/data/cloud/webdav/WebDavCloudContentRepositoryFactory.java @@ -26,7 +26,7 @@ public class WebDavCloudContentRepositoryFactory implements CloudContentReposito @Override public boolean supports(Cloud cloud) { - return cloud.type() == WEBDAV; + return cloud.getType() == WEBDAV; } @Override diff --git a/data/src/main/java/org/cryptomator/data/db/mappers/CloudEntityMapper.java b/data/src/main/java/org/cryptomator/data/db/mappers/CloudEntityMapper.java index 70e049f7a..236ab766a 100644 --- a/data/src/main/java/org/cryptomator/data/db/mappers/CloudEntityMapper.java +++ b/data/src/main/java/org/cryptomator/data/db/mappers/CloudEntityMapper.java @@ -89,8 +89,8 @@ public Cloud fromEntity(CloudEntity entity) { public CloudEntity toEntity(Cloud domainObject) { CloudEntity result = new CloudEntity(); result.setId(domainObject.id()); - result.setType(domainObject.type().name()); - switch (domainObject.type()) { + result.setType(domainObject.getType().name()); + switch (domainObject.getType()) { case DROPBOX: result.setAccessToken(((DropboxCloud) domainObject).accessToken()); result.setUsername(((DropboxCloud) domainObject).username()); @@ -126,7 +126,7 @@ public CloudEntity toEntity(Cloud domainObject) { result.setWebdavCertificate(((WebDavCloud) domainObject).certificate()); break; default: - throw new IllegalStateException("Unhandled enum constant " + domainObject.type()); + throw new IllegalStateException("Unhandled enum constant " + domainObject.getType()); } return result; } diff --git a/data/src/main/java/org/cryptomator/data/repository/CloudRepositoryImpl.java b/data/src/main/java/org/cryptomator/data/repository/CloudRepositoryImpl.java index f08137f2f..a6efa7f0b 100644 --- a/data/src/main/java/org/cryptomator/data/repository/CloudRepositoryImpl.java +++ b/data/src/main/java/org/cryptomator/data/repository/CloudRepositoryImpl.java @@ -47,7 +47,7 @@ public List clouds(CloudType cloudType) throws BackendException { List allClouds = mapper.fromEntities(database.loadAll(CloudEntity.class)); for (Cloud cloud : allClouds) { - if (cloud.type().equals(cloudType)) { + if (cloud.getType().equals(cloudType)) { cloudsFromType.add(cloud); } } diff --git a/data/src/test/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProviderTest.kt b/data/src/test/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProviderTest.kt index 67d3bb4de..293de6955 100644 --- a/data/src/test/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProviderTest.kt +++ b/data/src/test/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProviderTest.kt @@ -156,7 +156,7 @@ internal class MasterkeyCryptoCloudProviderTest { fun testUnlockVault() { val cloudType: CloudType = mock() - whenever(cloud.type()).thenReturn(cloudType) + whenever(cloud.type).thenReturn(cloudType) whenever(vault.cloud).thenReturn(cloud) whenever(vault.cloudType).thenReturn(cloudType) whenever(vault.format).thenReturn(8) @@ -183,7 +183,7 @@ internal class MasterkeyCryptoCloudProviderTest { fun testUnlockLegacyVault() { val cloudType: CloudType = mock() - whenever(cloud.type()).thenReturn(cloudType) + whenever(cloud.type).thenReturn(cloudType) whenever(vault.cloud).thenReturn(cloud) whenever(vault.cloudType).thenReturn(cloudType) whenever(vault.format).thenReturn(7) @@ -217,7 +217,7 @@ internal class MasterkeyCryptoCloudProviderTest { fun tesChangePassword(legacy: Boolean) { val cloudType: CloudType = mock() - whenever(cloud.type()).thenReturn(cloudType) + whenever(cloud.type).thenReturn(cloudType) whenever(vault.cloud).thenReturn(cloud) whenever(vault.cloudType).thenReturn(cloudType) whenever(vault.format).thenReturn(7) @@ -334,7 +334,7 @@ internal class MasterkeyCryptoCloudProviderTest { private fun testVaultPasswordVault(masterkeyContent: String, unverifiedVaultConfig: Optional, password: String): Boolean { val cloudType: CloudType = mock() - whenever(cloud.type()).thenReturn(cloudType) + whenever(cloud.type).thenReturn(cloudType) whenever(vault.cloud).thenReturn(cloud) whenever(vault.cloudType).thenReturn(cloudType) whenever(vault.format).thenReturn(7) diff --git a/domain/src/main/java/org/cryptomator/domain/Cloud.kt b/domain/src/main/java/org/cryptomator/domain/Cloud.kt index 0b8a53228..b6bba4f3e 100644 --- a/domain/src/main/java/org/cryptomator/domain/Cloud.kt +++ b/domain/src/main/java/org/cryptomator/domain/Cloud.kt @@ -5,7 +5,7 @@ import java.io.Serializable interface Cloud : Serializable { fun id(): Long? - fun type(): CloudType + val type: CloudType fun configurationMatches(cloud: Cloud?): Boolean fun persistent(): Boolean fun requiresNetwork(): Boolean diff --git a/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java b/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java index 448429031..caba397bd 100644 --- a/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/DropboxCloud.java @@ -40,7 +40,7 @@ public String username() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.DROPBOX; } diff --git a/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java b/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java index 68ad9017b..e712235d4 100644 --- a/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/GoogleDriveCloud.java @@ -32,7 +32,7 @@ public Long id() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.GOOGLE_DRIVE; } diff --git a/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java b/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java index 57b2dd209..7460a0c18 100644 --- a/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/LocalStorageCloud.java @@ -34,7 +34,7 @@ public String rootUri() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.LOCAL; } diff --git a/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java b/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java index 530d0eb77..dd08b4059 100644 --- a/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/OnedriveCloud.java @@ -40,7 +40,7 @@ public String username() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.ONEDRIVE; } diff --git a/domain/src/main/java/org/cryptomator/domain/PCloud.java b/domain/src/main/java/org/cryptomator/domain/PCloud.java index b0e8e60e1..33b52b4fb 100644 --- a/domain/src/main/java/org/cryptomator/domain/PCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/PCloud.java @@ -47,7 +47,7 @@ public String username() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.PCLOUD; } diff --git a/domain/src/main/java/org/cryptomator/domain/S3Cloud.java b/domain/src/main/java/org/cryptomator/domain/S3Cloud.java index b92c68fb6..8dd86fa8b 100644 --- a/domain/src/main/java/org/cryptomator/domain/S3Cloud.java +++ b/domain/src/main/java/org/cryptomator/domain/S3Cloud.java @@ -68,7 +68,7 @@ public String displayName() { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.S3; } diff --git a/domain/src/main/java/org/cryptomator/domain/Vault.java b/domain/src/main/java/org/cryptomator/domain/Vault.java index de66a6a76..555fe3b18 100644 --- a/domain/src/main/java/org/cryptomator/domain/Vault.java +++ b/domain/src/main/java/org/cryptomator/domain/Vault.java @@ -159,7 +159,7 @@ public Builder withCloud(Cloud cloud) { this.cloud = cloud; if (cloud != null) { - this.cloudType = cloud.type(); + this.cloudType = cloud.getType(); } return this; @@ -168,7 +168,7 @@ public Builder withCloud(Cloud cloud) { public Builder withCloudType(CloudType cloudType) { this.cloudType = cloudType; - if (cloud != null && cloud.type() != cloudType) { + if (cloud != null && cloud.getType() != cloudType) { throw new IllegalStateException("Cloud type must match cloud"); } @@ -179,7 +179,7 @@ public Builder withNamePathAndCloudFrom(CloudFolder vaultFolder) { this.name = vaultFolder.getName(); this.path = vaultFolder.getPath(); this.cloud = vaultFolder.getCloud(); - this.cloudType = cloud.type(); + this.cloudType = cloud.getType(); return this; } diff --git a/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java b/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java index bedf399a3..9e0b73f09 100644 --- a/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/WebDavCloud.java @@ -47,7 +47,7 @@ private boolean configurationMatches(WebDavCloud cloud) { @NotNull @Override - public CloudType type() { + public CloudType getType() { return CloudType.WEBDAV; } diff --git a/domain/src/main/java/org/cryptomator/domain/usecases/cloud/AddOrChangeCloudConnection.java b/domain/src/main/java/org/cryptomator/domain/usecases/cloud/AddOrChangeCloudConnection.java index 829eaee3b..d395737e2 100644 --- a/domain/src/main/java/org/cryptomator/domain/usecases/cloud/AddOrChangeCloudConnection.java +++ b/domain/src/main/java/org/cryptomator/domain/usecases/cloud/AddOrChangeCloudConnection.java @@ -33,7 +33,7 @@ public void execute() throws BackendException { } private boolean cloudExists(Cloud cloud) throws BackendException { - for (Cloud storedCloud : cloudRepository.clouds(cloud.type())) { + for (Cloud storedCloud : cloudRepository.clouds(cloud.getType())) { if (cloud.id() != null && cloud.id().equals(storedCloud.id())) { continue; } diff --git a/domain/src/main/java/org/cryptomator/domain/usecases/cloud/LogoutCloud.java b/domain/src/main/java/org/cryptomator/domain/usecases/cloud/LogoutCloud.java index 3ea926a98..829673807 100644 --- a/domain/src/main/java/org/cryptomator/domain/usecases/cloud/LogoutCloud.java +++ b/domain/src/main/java/org/cryptomator/domain/usecases/cloud/LogoutCloud.java @@ -48,6 +48,6 @@ private Cloud cloudWithUsernameAndAccessTokenRemoved(Cloud cloud) { .withAccessToken(null) // .build(); } - throw new IllegalStateException("Logout not supported for cloud with type " + cloud.type()); + throw new IllegalStateException("Logout not supported for cloud with type " + cloud.getType()); } } diff --git a/presentation/src/main/java/org/cryptomator/presentation/model/CloudFolderModel.kt b/presentation/src/main/java/org/cryptomator/presentation/model/CloudFolderModel.kt index 1d53cea8e..436ee3ac4 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/model/CloudFolderModel.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/model/CloudFolderModel.kt @@ -17,7 +17,7 @@ class CloudFolderModel(cloudFolder: CloudFolder) : CloudNodeModel(c get() = true fun vault(): VaultModel? { - return if (toCloudNode().cloud?.type() == CloudType.CRYPTO) { + return if (toCloudNode().cloud?.type == CloudType.CRYPTO) { VaultModel((toCloudNode().cloud as CryptoCloud).vault) } else { null diff --git a/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt b/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt index 48a09a13e..770e8aa1e 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/model/mappers/CloudModelMapper.kt @@ -22,7 +22,7 @@ class CloudModelMapper @Inject constructor() : ModelMapper() } override fun toModel(domainObject: Cloud): CloudModel { - return when (domainObject.type().let { CloudTypeModel.valueOf(it) }) { + return when (domainObject.type.let { CloudTypeModel.valueOf(it) }) { CloudTypeModel.DROPBOX -> DropboxCloudModel(domainObject) CloudTypeModel.GOOGLE_DRIVE -> GoogleDriveCloudModel(domainObject) CloudTypeModel.LOCAL -> LocalStorageModel(domainObject) diff --git a/presentation/src/main/java/org/cryptomator/presentation/presenter/AuthenticateCloudPresenter.kt b/presentation/src/main/java/org/cryptomator/presentation/presenter/AuthenticateCloudPresenter.kt index 04f9ef45c..b0d19b209 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/presenter/AuthenticateCloudPresenter.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/presenter/AuthenticateCloudPresenter.kt @@ -114,10 +114,10 @@ class AuthenticateCloudPresenter @Inject constructor( // } private fun updateUsernameOf(cloud: Cloud, username: String): Cloud { - return when (cloud.type()) { + return when (cloud.type) { CloudType.DROPBOX -> DropboxCloud.aCopyOf(cloud as DropboxCloud).withUsername(username).build() CloudType.ONEDRIVE -> OnedriveCloud.aCopyOf(cloud as OnedriveCloud).withUsername(username).build() - else -> throw IllegalStateException("Cloud " + cloud.type() + " is not supported") + else -> throw IllegalStateException("Cloud " + cloud.type + " is not supported") } } @@ -336,7 +336,7 @@ class AuthenticateCloudPresenter @Inject constructor( // fun prepareForSavingPCloud(cloud: PCloud) { getCloudsUseCase // - .withCloudType(cloud.type()) // + .withCloudType(cloud.type) // .run(object : DefaultResultHandler>() { override fun onSuccess(clouds: List) { clouds.firstOrNull {