refactor: adopt Kotlin 1.9's data objects

This commit is contained in:
Harsh Shandilya 2023-07-09 16:48:34 +05:30
parent 378ce98cd0
commit 6f3f7e4b4c
No known key found for this signature in database
4 changed files with 15 additions and 15 deletions

View file

@ -37,13 +37,13 @@ object BiometricAuthenticator {
* An incorrect biometric was entered, but the prompt UI is offering the option to retry the
* operation.
*/
object Retry : Result()
data object Retry : Result()
/** The biometric hardware is unavailable or disabled on a software or hardware level. */
object HardwareUnavailableOrDisabled : Result()
data object HardwareUnavailableOrDisabled : Result()
/** The prompt was dismissed. */
object Cancelled : Result()
data object Cancelled : Result()
}
fun canAuthenticate(activity: FragmentActivity): Boolean {

View file

@ -28,17 +28,17 @@ sealed class GitException(@StringRes res: Int, vararg fmt: String) :
/** Encapsulates possible errors from a [org.eclipse.jgit.api.PullCommand]. */
sealed class PullException(@StringRes res: Int, vararg fmt: String) : GitException(res, *fmt) {
object PullRebaseFailed : PullException(R.string.git_pull_rebase_fail_error)
data object PullRebaseFailed : PullException(R.string.git_pull_rebase_fail_error)
object PullMergeFailed : PullException(R.string.git_pull_merge_fail_error)
data object PullMergeFailed : PullException(R.string.git_pull_merge_fail_error)
}
/** Encapsulates possible errors from a [org.eclipse.jgit.api.PushCommand]. */
sealed class PushException(@StringRes res: Int, vararg fmt: String) : GitException(res, *fmt) {
object NonFastForward : PushException(R.string.git_push_nff_error)
data object NonFastForward : PushException(R.string.git_push_nff_error)
object RemoteRejected : PushException(R.string.git_push_other_error)
data object RemoteRejected : PushException(R.string.git_push_other_error)
class Generic(message: String) : PushException(R.string.git_push_generic_error, message)
}

View file

@ -135,9 +135,9 @@ constructor(
class AuthModeMismatch(val newProtocol: Protocol, val validModes: List<AuthMode>) :
UpdateConnectionSettingsResult()
object Valid : UpdateConnectionSettingsResult()
data object Valid : UpdateConnectionSettingsResult()
object FailedToParseUrl : UpdateConnectionSettingsResult()
data object FailedToParseUrl : UpdateConnectionSettingsResult()
}
fun updateConnectionSettingsIfValid(

View file

@ -9,21 +9,21 @@ public sealed class CryptoException(message: String? = null, cause: Throwable? =
public sealed class KeyManagerException(message: String? = null) : CryptoException(message)
/** Store contains no keys. */
public object NoKeysAvailableException : KeyManagerException("No keys were found")
public data object NoKeysAvailableException : KeyManagerException("No keys were found")
/** Key directory does not exist or cannot be accessed. */
public object KeyDirectoryUnavailableException :
public data object KeyDirectoryUnavailableException :
KeyManagerException("Key directory does not exist")
/** Failed to delete given key. */
public object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
public data object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
/** Failed to parse the key as a known type. */
public object InvalidKeyException :
public data object InvalidKeyException :
KeyManagerException("Given key cannot be parsed as a known key type")
/** Key failed the [app.passwordstore.crypto.KeyUtils.isKeyUsable] test. */
public object UnusableKeyException :
public data object UnusableKeyException :
KeyManagerException("Given key is not usable for encryption - is it using AEAD?")
/** No key matching `keyId` could be found. */
@ -42,7 +42,7 @@ public sealed class CryptoHandlerException(message: String? = null, cause: Throw
public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause)
/** No keys were passed to the encrypt/decrypt operation. */
public object NoKeysProvidedException : CryptoHandlerException(null, null)
public data object NoKeysProvidedException : CryptoHandlerException(null, null)
/** An unexpected error that cannot be mapped to a known type. */
public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause)