Remove Enumeration type

Summary:
Enumeration used to be a type containing a single property value of type string.

The InspectableEnum is a type that had an Enumeration value and possible values.

As we removed possible values from the enum value, this structure no longer serves its purpose.

Reviewed By: antonk52

Differential Revision: D41400874

fbshipit-source-id: e5c2d1e15ee9b3074ddd69f75ee9b8150d44379f
This commit is contained in:
Lorenzo Blasa
2022-11-21 05:30:18 -08:00
committed by Facebook GitHub Bot
parent 5e200dd7ec
commit 5b3e110821
9 changed files with 16 additions and 25 deletions

View File

@@ -9,7 +9,6 @@ package com.facebook.flipper.plugins.uidebugger.common
import android.util.Log
import com.facebook.flipper.plugins.uidebugger.LogTag
import com.facebook.flipper.plugins.uidebugger.model.Enumeration
import com.facebook.flipper.plugins.uidebugger.model.InspectableValue
// Maintains 2 way mapping between some enum value and a readable string representation
@@ -40,7 +39,7 @@ open class EnumMapping<T>(private val mapping: Map<String, T>) {
}
fun toInspectable(value: T): InspectableValue.Enum {
return InspectableValue.Enum(Enumeration(getStringRepresentation(value)))
return InspectableValue.Enum(getStringRepresentation(value))
}
companion object {
const val NoMapping = "__UNKNOWN_ENUM_VALUE__"

View File

@@ -85,9 +85,7 @@ sealed class InspectableValue : Inspectable() {
@SerialName("enum")
@kotlinx.serialization.Serializable
data class Enum(
val value: com.facebook.flipper.plugins.uidebugger.model.Enumeration,
) : InspectableValue()
data class Enum(val value: String) : InspectableValue()
@SerialName("unknown")
@kotlinx.serialization.Serializable

View File

@@ -62,5 +62,3 @@ data class Size(
@Serializable(with = NumberSerializer::class) val width: Number,
@Serializable(with = NumberSerializer::class) val height: Number
) {}
@kotlinx.serialization.Serializable data class Enumeration(val value: String?)

View File

@@ -9,7 +9,6 @@ package com.facebook.flipper.plugins.uidebugger
import android.view.View
import com.facebook.flipper.plugins.uidebugger.common.EnumMapping
import com.facebook.flipper.plugins.uidebugger.model.Enumeration
import com.facebook.flipper.plugins.uidebugger.model.InspectableValue
import org.hamcrest.CoreMatchers.*
import org.hamcrest.MatcherAssert.assertThat
@@ -38,7 +37,6 @@ class EnumMappingTest {
@Test
fun testTurnsIntoEnumInspectable() {
assertThat(
visibility.toInspectable(View.GONE), equalTo(InspectableValue.Enum(Enumeration("GONE"))))
assertThat(visibility.toInspectable(View.GONE), equalTo(InspectableValue.Enum("GONE")))
}
}