From e7168c4a2e8b3f6d92cf52aa6f29d3c741b89ce6 Mon Sep 17 00:00:00 2001 From: Ergul Azizler Date: Fri, 25 Aug 2023 03:09:18 -0700 Subject: [PATCH] Revert D48588377: EZ cleanup of TurboReactPackage Differential Revision: D48588377 Original commit changeset: 5645acad938a Original Phabricator Diff: D48588377 fbshipit-source-id: e0da38e5b721d6bfc7fd6b4607c7712301330a8f --- .../com/facebook/react/TurboReactPackage.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java index 67d4b05b4b2..88eb2357b72 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java @@ -7,6 +7,7 @@ package com.facebook.react; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.facebook.react.bridge.ModuleHolder; import com.facebook.react.bridge.ModuleSpec; @@ -38,8 +39,9 @@ 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 name of the Native Module - * @param reactContext {@link ReactApplicationContext} context for this + * @param name + * @param reactContext + * @return */ public abstract @Nullable NativeModule getModule( String name, final ReactApplicationContext reactContext); @@ -58,10 +60,13 @@ public abstract class TurboReactPackage implements ReactPackage { final Set> entrySet = getReactModuleInfoProvider().getReactModuleInfos().entrySet(); final Iterator> entrySetIterator = entrySet.iterator(); - // This should ideally be an IteratorConvertor, but we don't have any internal library for it - return () -> - new Iterator() { - @Nullable Map.Entry nextEntry = null; + return new Iterable() { + @NonNull + @Override + // This should ideally be an IteratorConvertor, but we don't have any internal library for it + public Iterator iterator() { + return new Iterator() { + Map.Entry nextEntry = null; private void findNext() { while (entrySetIterator.hasNext()) { @@ -113,6 +118,8 @@ public abstract class TurboReactPackage implements ReactPackage { throw new UnsupportedOperationException("Cannot remove native modules from the list"); } }; + } + }; } /**