Fix empty @ReactModuleList generated code

Reviewed By: AaaChiuuu

Differential Revision: D5737684

fbshipit-source-id: dc9312f595da23390cda14d5092c92d1e0319b83
This commit is contained in:
Zachary Liu 2017-08-30 13:47:04 -07:00 committed by Facebook Github Bot
parent fe0d081229
commit 42713c917e
1 changed files with 3 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import javax.lang.model.util.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;
import java.util.HashMap;
import java.util.List;
@ -55,6 +56,7 @@ import static javax.tools.Diagnostic.Kind.ERROR;
@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class ReactModuleSpecProcessor extends AbstractProcessor {
private static final TypeName COLLECTIONS_TYPE = ParameterizedTypeName.get(Collections.class);
private static final TypeName MAP_TYPE = ParameterizedTypeName.get(
Map.class,
Class.class,
@ -145,7 +147,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
throws ReactModuleSpecException {
CodeBlock.Builder builder = CodeBlock.builder();
if (nativeModules == null || nativeModules.isEmpty()) {
builder.addStatement("return Collections.emptyMap()");
builder.addStatement("return $T.emptyMap()", COLLECTIONS_TYPE);
} else {
builder.addStatement("$T map = new $T()", MAP_TYPE, INSTANTIATED_MAP_TYPE);