EZ cleanup of TurboReactPackage (#39165)

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

EZ cleanup of TurboReactPackage

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D48691696

fbshipit-source-id: 717ecddce5ff4ed0b655ed44b8d05c1798ac81df
This commit is contained in:
David Vacca
2023-08-29 15:20:09 -07:00
committed by Facebook GitHub Bot
parent a60e880882
commit 24c1428ed6
@@ -7,7 +7,6 @@
package com.facebook.react;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ModuleHolder;
import com.facebook.react.bridge.ModuleSpec;
@@ -39,9 +38,8 @@ public abstract class TurboReactPackage implements ReactPackage {
* The API needed for TurboModules. Given a module name, it returns an instance of {@link
* NativeModule} for the name
*
* @param name
* @param reactContext
* @return
* @param name name of the Native Module
* @param reactContext {@link ReactApplicationContext} context for this
*/
public abstract @Nullable NativeModule getModule(
String name, final ReactApplicationContext reactContext);
@@ -60,13 +58,10 @@ public abstract class TurboReactPackage implements ReactPackage {
final Set<Map.Entry<String, ReactModuleInfo>> entrySet =
getReactModuleInfoProvider().getReactModuleInfos().entrySet();
final Iterator<Map.Entry<String, ReactModuleInfo>> entrySetIterator = entrySet.iterator();
return new Iterable<ModuleHolder>() {
@NonNull
@Override
// This should ideally be an IteratorConvertor, but we don't have any internal library for it
public Iterator<ModuleHolder> iterator() {
return new Iterator<ModuleHolder>() {
Map.Entry<String, ReactModuleInfo> nextEntry = null;
// This should ideally be an IteratorConvertor, but we don't have any internal library for it
return () ->
new Iterator<ModuleHolder>() {
@Nullable Map.Entry<String, ReactModuleInfo> nextEntry = null;
private void findNext() {
while (entrySetIterator.hasNext()) {
@@ -118,8 +113,6 @@ public abstract class TurboReactPackage implements ReactPackage {
throw new UnsupportedOperationException("Cannot remove native modules from the list");
}
};
}
};
}
/**