Kotlinify ReadableMap (#43904)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43904

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: cortinico

Differential Revision: D55793535

fbshipit-source-id: 13ddcd97da4a6a2ccc61b13291f64e7f6c9ed459
This commit is contained in:
Fabrizio Cucci
2024-04-07 06:43:35 -07:00
committed by Facebook GitHub Bot
parent 9b54e226bd
commit bbb7d2cb9d
2 changed files with 46 additions and 57 deletions
@@ -1,57 +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.react.bridge;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Interface for a map that allows typed access to its members. Used to pass parameters from JS to
* Java.
*/
public interface ReadableMap {
boolean hasKey(@NonNull String name);
boolean isNull(@NonNull String name);
boolean getBoolean(@NonNull String name);
double getDouble(@NonNull String name);
int getInt(@NonNull String name);
long getLong(@NonNull String name);
@Nullable
String getString(@NonNull String name);
@Nullable
ReadableArray getArray(@NonNull String name);
@Nullable
ReadableMap getMap(@NonNull String name);
@NonNull
Dynamic getDynamic(@NonNull String name);
@NonNull
ReadableType getType(@NonNull String name);
@NonNull
Iterator<Map.Entry<String, Object>> getEntryIterator();
@NonNull
ReadableMapKeySetIterator keySetIterator();
@NonNull
HashMap<String, Object> toHashMap();
}
@@ -0,0 +1,46 @@
/*
* 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.react.bridge
import java.util.HashMap
import kotlin.collections.Iterator
import kotlin.collections.Map
/**
* Interface for a map that allows typed access to its members. Used to pass parameters from JS to
* Kotlin.
*/
public interface ReadableMap {
public fun getArray(name: String): ReadableArray?
public fun getBoolean(name: String): Boolean
public fun getDouble(name: String): Double
public fun getDynamic(name: String): Dynamic
public fun getEntryIterator(): Iterator<Map.Entry<String, Any>>
public fun getInt(name: String): Int
public fun getLong(name: String): Long
public fun getMap(name: String): ReadableMap?
public fun getString(name: String): String?
public fun getType(name: String): ReadableType
public fun hasKey(name: String): Boolean
public fun isNull(name: String): Boolean
public fun keySetIterator(): ReadableMapKeySetIterator
public fun toHashMap(): HashMap<String, Any>
}