From 8087edaafe27123b771ad2c81de2ceda67a85f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Tue, 12 Aug 2025 09:49:31 -0700 Subject: [PATCH] Migrate `YogaLayoutType` to Kotlin (#1837) Summary: Migrate com.facebook.yoga.YogaLayoutType to Kotlin. Pull Request resolved: https://github.com/facebook/yoga/pull/1837 Test Plan: RN ```sh yarn android yarn test-android ``` Yoga ```sh ./gradlew :yoga:assembleDebug ``` Reviewed By: rshest Differential Revision: D79897708 Pulled By: cortinico fbshipit-source-id: e3c8a3cc60f806d151d2be956b26dd98963254a6 --- java/com/facebook/yoga/YogaLayoutType.java | 35 ---------------------- java/com/facebook/yoga/YogaLayoutType.kt | 27 +++++++++++++++++ 2 files changed, 27 insertions(+), 35 deletions(-) delete mode 100644 java/com/facebook/yoga/YogaLayoutType.java create mode 100644 java/com/facebook/yoga/YogaLayoutType.kt diff --git a/java/com/facebook/yoga/YogaLayoutType.java b/java/com/facebook/yoga/YogaLayoutType.java deleted file mode 100644 index 8c861ff7..00000000 --- a/java/com/facebook/yoga/YogaLayoutType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.yoga; - -public enum YogaLayoutType { - LAYOUT(0), - MEASURE(1), - CACHED_LAYOUT(2), - CACHED_MEASURE(3); - - private final int mIntValue; - - YogaLayoutType(int intValue) { - mIntValue = intValue; - } - - public int intValue() { - return mIntValue; - } - - public static YogaLayoutType fromInt(int value) { - switch (value) { - case 0: return LAYOUT; - case 1: return MEASURE; - case 2: return CACHED_LAYOUT; - case 3: return CACHED_MEASURE; - default: throw new IllegalArgumentException("Unknown enum value: " + value); - } - } -} diff --git a/java/com/facebook/yoga/YogaLayoutType.kt b/java/com/facebook/yoga/YogaLayoutType.kt new file mode 100644 index 00000000..6177a412 --- /dev/null +++ b/java/com/facebook/yoga/YogaLayoutType.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.yoga + +public enum class YogaLayoutType(public val intValue: Int) { + LAYOUT(0), + MEASURE(1), + CACHED_LAYOUT(2), + CACHED_MEASURE(3); + + public companion object { + @JvmStatic + public fun fromInt(value: Int): YogaLayoutType = + when (value) { + 0 -> LAYOUT + 1 -> MEASURE + 2 -> CACHED_LAYOUT + 3 -> CACHED_MEASURE + else -> throw IllegalArgumentException("Unknown enum value: $value") + } + } +}