Skip to content

Commit d3317e5

Browse files
committed
Rename delegate state to component state
COSDK-480
1 parent 8044155 commit d3317e5

29 files changed

+174
-168
lines changed

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/DelegateState.kt renamed to core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/ComponentState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ package com.adyen.checkout.core.components.internal.ui.state
1111
import androidx.annotation.RestrictTo
1212

1313
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
14-
interface DelegateState {
14+
interface ComponentState {
1515
val isValid: Boolean
1616
}

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/DelegateStateFactory.kt renamed to core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/ComponentStateFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import androidx.annotation.RestrictTo
1212
import com.adyen.checkout.core.components.internal.ui.state.model.FieldId
1313

1414
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
15-
interface DelegateStateFactory<S : DelegateState, FI : FieldId> {
16-
fun createDefaultDelegateState(): S
15+
interface ComponentStateFactory<S : ComponentState, FI : FieldId> {
16+
fun createDefaultComponentState(): S
1717

1818
fun getFieldIds(): List<FI>
1919
}

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/DelegateStateManager.kt renamed to core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/ComponentStateManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import com.adyen.checkout.core.components.internal.ui.state.model.FieldId
1313
import kotlinx.coroutines.flow.StateFlow
1414

1515
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
16-
interface DelegateStateManager<S : DelegateState, FI : FieldId> {
16+
interface ComponentStateManager<S : ComponentState, FI : FieldId> {
1717

1818
val state: StateFlow<S>
1919

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
package com.adyen.checkout.core.components.internal.ui.state
1010

1111
import androidx.annotation.RestrictTo
12-
import com.adyen.checkout.core.components.internal.ui.state.model.DelegateFieldState
12+
import com.adyen.checkout.core.components.internal.ui.state.model.ComponentFieldState
1313
import com.adyen.checkout.core.components.internal.ui.state.model.FieldId
1414
import com.adyen.checkout.core.components.internal.ui.state.model.Validation
1515
import com.adyen.checkout.core.components.internal.ui.state.model.updateFieldState
@@ -23,14 +23,14 @@ import kotlinx.coroutines.flow.asStateFlow
2323
import kotlinx.coroutines.flow.update
2424

2525
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
26-
class DefaultDelegateStateManager<S : DelegateState, FI : FieldId>(
27-
private val factory: DelegateStateFactory<S, FI>,
26+
class DefaultComponentStateManager<S : ComponentState, FI : FieldId>(
27+
private val factory: ComponentStateFactory<S, FI>,
2828
private val validationRegistry: FieldValidatorRegistry<S, FI>,
2929
private val stateUpdaterRegistry: StateUpdaterRegistry<S, FI>,
3030
private val transformerRegistry: FieldTransformerRegistry<FI> = DefaultTransformerRegistry(),
31-
) : DelegateStateManager<S, FI> {
31+
) : ComponentStateManager<S, FI> {
3232

33-
private val _state = MutableStateFlow(factory.createDefaultDelegateState())
33+
private val _state = MutableStateFlow(factory.createDefaultComponentState())
3434
override val state: StateFlow<S> = _state.asStateFlow()
3535

3636
override val isValid: Boolean
@@ -46,7 +46,7 @@ class DefaultDelegateStateManager<S : DelegateState, FI : FieldId>(
4646
validateFields { fieldState -> fieldState.validation != null }
4747
}
4848

49-
private fun validateFields(validationPredicate: (DelegateFieldState<Any>) -> Boolean) {
49+
private fun validateFields(validationPredicate: (ComponentFieldState<Any>) -> Boolean) {
5050
factory.getFieldIds()
5151
.filter { fieldId ->
5252
val fieldState = stateUpdaterRegistry.getFieldState<Any>(_state.value, fieldId)

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/model/DelegateFieldState.kt renamed to core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/model/ComponentFieldState.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ package com.adyen.checkout.core.components.internal.ui.state.model
1111
import androidx.annotation.RestrictTo
1212

1313
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
14-
data class DelegateFieldState<T>(
14+
data class ComponentFieldState<T>(
1515
val value: T,
1616
val validation: Validation? = null,
1717
val hasFocus: Boolean = false,
1818
val shouldHighlightValidationError: Boolean = false,
1919
)
2020

2121
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
22-
fun <T> DelegateFieldState<T>.updateFieldState(
22+
fun <T> ComponentFieldState<T>.updateFieldState(
2323
value: T? = null,
2424
validation: Validation? = null,
2525
hasFocus: Boolean? = null,
2626
shouldHighlightValidationError: Boolean? = null,
27-
): DelegateFieldState<T> = copy(
27+
): ComponentFieldState<T> = copy(
2828
value = value ?: this.value,
2929
validation = validation ?: this.validation,
3030
hasFocus = hasFocus ?: this.hasFocus,
@@ -33,7 +33,7 @@ fun <T> DelegateFieldState<T>.updateFieldState(
3333
)
3434

3535
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
36-
fun <T> DelegateFieldState<T>.toViewFieldState() = ViewFieldState(
36+
fun <T> ComponentFieldState<T>.toViewFieldState() = ViewFieldState(
3737
value = value,
3838
hasFocus = hasFocus,
3939
errorMessageId = takeIf { fieldState ->
@@ -42,5 +42,5 @@ fun <T> DelegateFieldState<T>.toViewFieldState() = ViewFieldState(
4242
)
4343

4444
// Validation error should be shown, when the field loses its focus or when we manually trigger a validation
45-
internal fun <T> DelegateFieldState<T>.shouldShowValidationError() =
45+
internal fun <T> ComponentFieldState<T>.shouldShowValidationError() =
4646
!this.hasFocus || this.shouldHighlightValidationError

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/updater/StateUpdater.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
package com.adyen.checkout.core.components.internal.ui.state.updater
1010

1111
import androidx.annotation.RestrictTo
12-
import com.adyen.checkout.core.components.internal.ui.state.DelegateState
12+
import com.adyen.checkout.core.components.internal.ui.state.ComponentState
1313

1414
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
15-
interface StateUpdater<S : DelegateState, FS> {
15+
interface StateUpdater<S : ComponentState, FS> {
1616
fun getFieldState(state: S): FS
1717

1818
fun updateFieldState(state: S, fieldState: FS): S

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/updater/StateUpdaterRegistry.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
package com.adyen.checkout.core.components.internal.ui.state.updater
1010

1111
import androidx.annotation.RestrictTo
12-
import com.adyen.checkout.core.components.internal.ui.state.DelegateState
13-
import com.adyen.checkout.core.components.internal.ui.state.model.DelegateFieldState
12+
import com.adyen.checkout.core.components.internal.ui.state.ComponentState
13+
import com.adyen.checkout.core.components.internal.ui.state.model.ComponentFieldState
1414
import com.adyen.checkout.core.components.internal.ui.state.model.FieldId
1515

1616
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
17-
interface StateUpdaterRegistry<S : DelegateState, FI : FieldId> {
18-
fun <T> getFieldState(state: S, fieldId: FI): DelegateFieldState<T>
17+
interface StateUpdaterRegistry<S : ComponentState, FI : FieldId> {
18+
fun <T> getFieldState(state: S, fieldId: FI): ComponentFieldState<T>
1919

20-
fun <T> updateFieldState(state: S, fieldId: FI, fieldState: DelegateFieldState<T>): S
20+
fun <T> updateFieldState(state: S, fieldId: FI, fieldState: ComponentFieldState<T>): S
2121
}

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/validator/DefaultValidator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
package com.adyen.checkout.core.components.internal.ui.state.validator
1010

1111
import androidx.annotation.RestrictTo
12-
import com.adyen.checkout.core.components.internal.ui.state.DelegateState
12+
import com.adyen.checkout.core.components.internal.ui.state.ComponentState
1313
import com.adyen.checkout.core.components.internal.ui.state.model.Validation
1414

1515
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
16-
class DefaultValidator : FieldValidator<DelegateState, Any> {
17-
override fun validate(state: DelegateState, input: Any) = Validation.Valid
16+
class DefaultValidator : FieldValidator<ComponentState, Any> {
17+
override fun validate(state: ComponentState, input: Any) = Validation.Valid
1818
}

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/validator/FieldValidator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
package com.adyen.checkout.core.components.internal.ui.state.validator
1010

1111
import androidx.annotation.RestrictTo
12-
import com.adyen.checkout.core.components.internal.ui.state.DelegateState
12+
import com.adyen.checkout.core.components.internal.ui.state.ComponentState
1313
import com.adyen.checkout.core.components.internal.ui.state.model.Validation
1414

1515
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
16-
fun interface FieldValidator<S : DelegateState, T> {
16+
fun interface FieldValidator<S : ComponentState, T> {
1717
fun validate(state: S, input: T): Validation
1818
}

core/src/main/java/com/adyen/checkout/core/components/internal/ui/state/validator/FieldValidatorRegistry.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
package com.adyen.checkout.core.components.internal.ui.state.validator
1010

1111
import androidx.annotation.RestrictTo
12-
import com.adyen.checkout.core.components.internal.ui.state.DelegateState
12+
import com.adyen.checkout.core.components.internal.ui.state.ComponentState
1313
import com.adyen.checkout.core.components.internal.ui.state.model.FieldId
1414
import com.adyen.checkout.core.components.internal.ui.state.model.Validation
1515

1616
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
17-
interface FieldValidatorRegistry<S : DelegateState, FI : FieldId> {
17+
interface FieldValidatorRegistry<S : ComponentState, FI : FieldId> {
1818
fun <T> validate(state: S, fieldId: FI, value: T): Validation
1919
}

0 commit comments

Comments
 (0)