Skip to content

Commit 0901867

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Migrate YogaAlign enum to Kotlin (#1947)
Summary: Pull Request resolved: #1947 X-link: react/react-native#56783 Migrate YogaAlign.java to YogaAlign.kt by adding Align to KOTLIN_ENUM_NAMES in enums.py and regenerating. Changelog: [Internal] - Reviewed By: fabriziocucci Differential Revision: D104666334 fbshipit-source-id: b14bdd56104e41fd68c7f98aeae341e3f6e4ec23
1 parent d5c79d8 commit 0901867

3 files changed

Lines changed: 46 additions & 52 deletions

File tree

enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
}
9696

9797
# Temporary filter enums to not upgrade all enums at once
98-
KOTLIN_ENUM_NAMES = {"Direction"}
98+
KOTLIN_ENUM_NAMES = {"Direction", "Align"}
9999

100100
ENUMS_KOTLIN = {name: ENUMS[name] for name in KOTLIN_ENUM_NAMES}
101101
ENUMS_JAVA = {

java/com/facebook/yoga/YogaAlign.java

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// @generated by enums.py
9+
10+
package com.facebook.yoga
11+
12+
public enum class YogaAlign(public val intValue: Int) {
13+
AUTO(0),
14+
FLEX_START(1),
15+
CENTER(2),
16+
FLEX_END(3),
17+
STRETCH(4),
18+
BASELINE(5),
19+
SPACE_BETWEEN(6),
20+
SPACE_AROUND(7),
21+
SPACE_EVENLY(8),
22+
START(9),
23+
END(10);
24+
25+
public fun intValue(): Int = intValue
26+
27+
public companion object {
28+
@JvmStatic
29+
public fun fromInt(value: Int): YogaAlign =
30+
when (value) {
31+
0 -> AUTO
32+
1 -> FLEX_START
33+
2 -> CENTER
34+
3 -> FLEX_END
35+
4 -> STRETCH
36+
5 -> BASELINE
37+
6 -> SPACE_BETWEEN
38+
7 -> SPACE_AROUND
39+
8 -> SPACE_EVENLY
40+
9 -> START
41+
10 -> END
42+
else -> throw IllegalArgumentException("Unknown enum value: $value")
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)