Immutable data class. var -> val

This commit is contained in:
Benoit Marty 2022-04-13 19:25:08 +02:00
parent 7773b75834
commit 015438289e
11 changed files with 46 additions and 45 deletions

View File

@ -24,8 +24,8 @@ import kotlinx.parcelize.Parcelize
*/
@Parcelize
data class LocalizedFlowDataLoginTerms(
var policyName: String? = null,
var version: String? = null,
var localizedUrl: String? = null,
var localizedName: String? = null
val policyName: String?,
val version: String?,
val localizedUrl: String?,
val localizedName: String?
) : Parcelable

View File

@ -22,12 +22,12 @@ import org.matrix.android.sdk.internal.crypto.model.CryptoInfo
data class CryptoDeviceInfo(
val deviceId: String,
override val userId: String,
var algorithms: List<String>? = null,
val algorithms: List<String>? = null,
override val keys: Map<String, String>? = null,
override val signatures: Map<String, Map<String, String>>? = null,
val unsigned: UnsignedDeviceInfo? = null,
var trustLevel: DeviceTrustLevel? = null,
var isBlocked: Boolean = false,
val isBlocked: Boolean = false,
val firstTimeSeenLocalTs: Long? = null
) : CryptoInfo {

View File

@ -25,14 +25,14 @@ import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequest
@JsonClass(generateAdapter = true)
data class OutgoingRoomKeyRequest(
// RequestBody
var requestBody: RoomKeyRequestBody?,
val requestBody: RoomKeyRequestBody?,
// list of recipients for the request
override var recipients: Map<String, List<String>>,
override val recipients: Map<String, List<String>>,
// Unique id for this request. Used for both
// an id within the request for later pairing with a cancellation, and for
// the transaction id when sending the to_device messages to our local
override var requestId: String, // current state of this request
override var state: OutgoingGossipingRequestState
override val requestId: String, // current state of this request
override val state: OutgoingGossipingRequestState
// transaction id for the cancellation, if any
// override var cancellationTxnId: String? = null
) : OutgoingGossipingRequest {
@ -43,9 +43,7 @@ data class OutgoingRoomKeyRequest(
* @return the room id.
*/
val roomId: String?
get() = if (null != requestBody) {
requestBody!!.roomId
} else null
get() = requestBody?.roomId
/**
* Used only for log.
@ -53,7 +51,5 @@ data class OutgoingRoomKeyRequest(
* @return the session id
*/
val sessionId: String?
get() = if (null != requestBody) {
requestBody!!.sessionId
} else null
get() = requestBody?.sessionId
}

View File

@ -16,9 +16,9 @@
package org.matrix.android.sdk.api.session.room.model
data class EventAnnotationsSummary(
var eventId: String,
var reactionsSummary: List<ReactionAggregatedSummary> = emptyList(),
var editSummary: EditAggregatedSummary? = null,
var pollResponseSummary: PollResponseAggregatedSummary? = null,
var referencesAggregatedSummary: ReferencesAggregatedSummary? = null
val eventId: String,
val reactionsSummary: List<ReactionAggregatedSummary> = emptyList(),
val editSummary: EditAggregatedSummary? = null,
val pollResponseSummary: PollResponseAggregatedSummary? = null,
val referencesAggregatedSummary: ReferencesAggregatedSummary? = null
)

View File

@ -16,13 +16,11 @@
package org.matrix.android.sdk.api.session.room.model
data class PollResponseAggregatedSummary(
var aggregatedContent: PollSummaryContent? = null,
val aggregatedContent: PollSummaryContent? = null,
// If set the poll is closed (Clients SHOULD NOT consider responses after the close event)
var closedTime: Long? = null,
val closedTime: Long? = null,
// Clients SHOULD validate that the option in the relationship is a valid option, and ignore the response if invalid
var nbOptions: Int = 0,
val nbOptions: Int = 0,
// The list of the eventIDs used to build the summary (might be out of sync if chunked received from message chunk)
val sourceEvents: List<String>,
val localEchos: List<String>

View File

@ -56,7 +56,7 @@ data class TimelineEvent(
* It's not unique on the timeline as it's reset on each chunk.
*/
val displayIndex: Int,
var ownedByThreadChunk: Boolean = false,
val ownedByThreadChunk: Boolean = false,
val senderInfo: SenderInfo,
val annotations: EventAnnotationsSummary? = null,
val readReceipts: List<ReadReceipt> = emptyList()

View File

@ -18,7 +18,7 @@ package org.matrix.android.sdk.api.session.securestorage
data class SsssKeyCreationInfo(
val keyId: String = "",
var content: SecretStorageKeyContent?,
val content: SecretStorageKeyContent?,
val recoveryKey: String = "",
val keySpec: SsssKeySpec
)

View File

@ -29,7 +29,7 @@ data class ThreadDetails(
val threadSummarySenderInfo: SenderInfo? = null,
val threadSummaryLatestEvent: Event? = null,
val lastMessageTimestamp: Long? = null,
var threadNotificationState: ThreadNotificationState = ThreadNotificationState.NO_NEW_MESSAGE,
val threadNotificationState: ThreadNotificationState = ThreadNotificationState.NO_NEW_MESSAGE,
val isThread: Boolean = false,
val lastRootThreadEdition: String? = null
)

View File

@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto
import org.matrix.android.sdk.api.session.crypto.model.OutgoingGossipingRequestState
internal interface OutgoingGossipingRequest {
var recipients: Map<String, List<String>>
var requestId: String
var state: OutgoingGossipingRequestState
val recipients: Map<String, List<String>>
val requestId: String
val state: OutgoingGossipingRequestState
// transaction id for the cancellation, if any
// var cancellationTxnId: String?
}

View File

@ -30,17 +30,17 @@ internal data class BindThreePidBody(
* Required. The identity server to use. (without "https://")
*/
@Json(name = "id_server")
var identityServerUrlWithoutProtocol: String,
val identityServerUrlWithoutProtocol: String,
/**
* Required. An access token previously registered with the identity server.
*/
@Json(name = "id_access_token")
var identityServerAccessToken: String,
val identityServerAccessToken: String,
/**
* Required. The session identifier given by the identity server.
*/
@Json(name = "sid")
var sid: String
val sid: String
)

View File

@ -48,15 +48,17 @@ fun TermPolicies.toLocalizedLoginTerms(userLanguage: String,
val policies = get("policies")
if (policies is Map<*, *>) {
policies.keys.forEach { policyName ->
val localizedFlowDataLoginTerms = LocalizedFlowDataLoginTerms()
localizedFlowDataLoginTerms.policyName = policyName as String
val localizedFlowDataLoginTermsPolicyName = policyName as String
var localizedFlowDataLoginTermsVersion: String? = null
var localizedFlowDataLoginTermsLocalizedUrl: String? = null
var localizedFlowDataLoginTermsLocalizedName: String? = null
val policy = policies[policyName]
// Enter this policy
if (policy is Map<*, *>) {
// Version
localizedFlowDataLoginTerms.version = policy["version"] as String?
localizedFlowDataLoginTermsVersion = policy["version"] as String?
var userLanguageUrlAndName: UrlAndName? = null
var defaultLanguageUrlAndName: UrlAndName? = null
@ -86,21 +88,26 @@ fun TermPolicies.toLocalizedLoginTerms(userLanguage: String,
// Copy found language data by priority
when {
userLanguageUrlAndName != null -> {
localizedFlowDataLoginTerms.localizedUrl = userLanguageUrlAndName!!.url
localizedFlowDataLoginTerms.localizedName = userLanguageUrlAndName!!.name
localizedFlowDataLoginTermsLocalizedUrl = userLanguageUrlAndName!!.url
localizedFlowDataLoginTermsLocalizedName = userLanguageUrlAndName!!.name
}
defaultLanguageUrlAndName != null -> {
localizedFlowDataLoginTerms.localizedUrl = defaultLanguageUrlAndName!!.url
localizedFlowDataLoginTerms.localizedName = defaultLanguageUrlAndName!!.name
localizedFlowDataLoginTermsLocalizedUrl = defaultLanguageUrlAndName!!.url
localizedFlowDataLoginTermsLocalizedName = defaultLanguageUrlAndName!!.name
}
firstUrlAndName != null -> {
localizedFlowDataLoginTerms.localizedUrl = firstUrlAndName!!.url
localizedFlowDataLoginTerms.localizedName = firstUrlAndName!!.name
localizedFlowDataLoginTermsLocalizedUrl = firstUrlAndName!!.url
localizedFlowDataLoginTermsLocalizedName = firstUrlAndName!!.name
}
}
}
result.add(localizedFlowDataLoginTerms)
result.add(LocalizedFlowDataLoginTerms(
policyName = localizedFlowDataLoginTermsPolicyName,
version = localizedFlowDataLoginTermsVersion,
localizedUrl = localizedFlowDataLoginTermsLocalizedUrl,
localizedName = localizedFlowDataLoginTermsLocalizedName
))
}
}