Skip to content

Commit 1ed96cb

Browse files
Rename states
1 parent a6fb745 commit 1ed96cb

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

jsontree/src/commonMain/kotlin/com/sebastianneubauer/jsontree/diff/JsonTreeDiff.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import androidx.compose.ui.unit.dp
2626
import com.sebastianneubauer.jsontree.CollapsableType
2727
import com.sebastianneubauer.jsontree.JsonTreeElement
2828
import com.sebastianneubauer.jsontree.diff.JsonTreeDifferState.JsonDiffElement
29-
import com.sebastianneubauer.jsontree.diff.JsonTreeDiffError.OriginalJsonError
30-
import com.sebastianneubauer.jsontree.diff.JsonTreeDiffError.RevisedJsonError
29+
import com.sebastianneubauer.jsontree.diff.DiffError.OriginalJsonError
30+
import com.sebastianneubauer.jsontree.diff.DiffError.RevisedJsonError
3131
import kotlinx.coroutines.Dispatchers
3232

3333
/**
@@ -36,8 +36,8 @@ import kotlinx.coroutines.Dispatchers
3636
* @param originalJson The original JSON data as a string.
3737
* @param revisedJson The revised JSON data as a string which is compared with [originalJson].
3838
* @param onLoading A Composable which is show while the diff is being calculated.
39-
* @param onError A Composable which is shown if an error occurs. Receives an [Error] object with more information.
40-
* @param onSuccess A callback which is called when the diff calculation succeeded. Receives an [Success] object with more information.
39+
* @param onError A Composable which is shown if an error occurs. Receives an [JsonTreeDiffError] object with more information.
40+
* @param onSuccess A callback which is called when the diff calculation succeeded. Receives an [JsonTreeDiffSuccess] object with more information.
4141
* @param modifier The Modifier which is applied on the side-by-side diff. Not applied on the [onLoading] and [onError] slots.
4242
* @param showInlineDiffs If true, the diff shows partial changes within the text of a line.
4343
* @param contentPadding The content padding which is applied on the LazyColumn of the side-by-side diff.
@@ -49,8 +49,8 @@ public fun JsonTreeDiff(
4949
originalJson: String,
5050
revisedJson: String,
5151
onLoading: @Composable () -> Unit,
52-
onError: @Composable (Error) -> Unit,
53-
onSuccess: (Success) -> Unit= {},
52+
onError: @Composable (JsonTreeDiffError) -> Unit,
53+
onSuccess: (JsonTreeDiffSuccess) -> Unit= {},
5454
modifier: Modifier = Modifier,
5555
showInlineDiffs: Boolean = false,
5656
contentPadding: PaddingValues = PaddingValues(0.dp),
@@ -76,7 +76,7 @@ public fun JsonTreeDiff(
7676
when(val state = jsonTreeDiffer.state.value) {
7777
is JsonTreeDifferState.Loading -> onLoading()
7878
is JsonTreeDifferState.Ready -> {
79-
onSuccess(Success(state.diffInfo))
79+
onSuccess(JsonTreeDiffSuccess(state.diffInfo))
8080

8181
Box(modifier = modifier) {
8282
SideBySideDiff(
@@ -87,8 +87,8 @@ public fun JsonTreeDiff(
8787
)
8888
}
8989
}
90-
is JsonTreeDifferState.Error.OriginalJsonError -> onError(Error(OriginalJsonError(state.throwable)))
91-
is JsonTreeDifferState.Error.RevisedJsonError -> onError(Error(RevisedJsonError(state.throwable)))
90+
is JsonTreeDifferState.Error.OriginalJsonError -> onError(JsonTreeDiffError(OriginalJsonError(state.throwable)))
91+
is JsonTreeDifferState.Error.RevisedJsonError -> onError(JsonTreeDiffError(RevisedJsonError(state.throwable)))
9292
}
9393
}
9494

jsontree/src/commonMain/kotlin/com/sebastianneubauer/jsontree/diff/JsonTreeDiffState.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.sebastianneubauer.jsontree.diff
33
/**
44
* The diff calculation succeeded. See [info] for more details on the diff.
55
*/
6-
public data class Success(val info: JsonTreeDiffInfo)
6+
public data class JsonTreeDiffSuccess(val info: JsonTreeDiffInfo)
77

88
/**
99
* Infos about the calculated diff.
@@ -26,17 +26,17 @@ public data class ChangeInfo(
2626
/**
2727
* The diff calculation failed with an error. See [error] for details.
2828
*/
29-
public data class Error(val error: JsonTreeDiffError)
29+
public data class JsonTreeDiffError(val error: DiffError)
3030

31-
public interface JsonTreeDiffError {
31+
public sealed interface DiffError {
3232
public val throwable: Throwable
3333
/**
3434
* Describes an error during parsing of the original Json.
3535
*/
36-
public class OriginalJsonError(override val throwable: Throwable): JsonTreeDiffError
36+
public class OriginalJsonError(override val throwable: Throwable): DiffError
3737

3838
/**
3939
* Describes an error during parsing of the revised Json.
4040
*/
41-
public class RevisedJsonError(override val throwable: Throwable): JsonTreeDiffError
41+
public class RevisedJsonError(override val throwable: Throwable): DiffError
4242
}

0 commit comments

Comments
 (0)