Convert `NegativeSmtpReplyException` to Kotlin
-package com.fsck.k9.mail.transport.smtp;
-
-
-import android.text.TextUtils;
-
-import com.fsck.k9.mail.MessagingException;
+package com.fsck.k9.mail.transport.smtp
+import com.fsck.k9.mail.MessagingException
/**
* Exception that is thrown when the server sends a negative reply (reply codes 4xx or 5xx).
*/
-class NegativeSmtpReplyException extends MessagingException {
- private static final long serialVersionUID = 8696043577357897135L;
-
-
- private final int replyCode;
- private final String replyText;
-
-
- public NegativeSmtpReplyException(int replyCode, String replyText) {
- super(buildErrorMessage(replyCode, replyText), isPermanentSmtpError(replyCode));
- this.replyCode = replyCode;
- this.replyText = replyText;
+open class NegativeSmtpReplyException(
+ val replyCode: Int,
+ val replyText: String
+) : MessagingException(
+ buildErrorMessage(replyCode, replyText),
+ isPermanentSmtpError(replyCode)
+)
+
+private fun buildErrorMessage(replyCode: Int, replyText: String): String {
+ return replyText.ifEmpty { "Negative SMTP reply: $replyCode" }
}
- private static String buildErrorMessage(int replyCode, String replyText) {
- return TextUtils.isEmpty(replyText) ? "Negative SMTP reply: " + replyCode : replyText;
- }
-
- private static boolean isPermanentSmtpError(int replyCode) {
- return replyCode >= 500 && replyCode <= 599;
- }
-
- public int getReplyCode() {
- return replyCode;
- }
-
- public String getReplyText() {
- return replyText;
- }
+private fun isPermanentSmtpError(replyCode: Int): Boolean {
+ return replyCode in 500..599
}
