From 22eede870fa92823c97a6ea133040daa74bfc217 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Mon, 15 Oct 2012 22:13:19 -0700 Subject: [PATCH] Change ImmutableList.convert to return an empty list rather than null --- .../main/java/org/jf/util/ImmutableListConverter.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/src/main/java/org/jf/util/ImmutableListConverter.java b/util/src/main/java/org/jf/util/ImmutableListConverter.java index 17d9e400..a1c902d8 100644 --- a/util/src/main/java/org/jf/util/ImmutableListConverter.java +++ b/util/src/main/java/org/jf/util/ImmutableListConverter.java @@ -33,6 +33,7 @@ package org.jf.util; import com.google.common.collect.ImmutableList; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Iterator; import java.util.List; @@ -48,14 +49,15 @@ public abstract class ImmutableListConverter { * Converts a {@code List} of {@code Item}s to an {@code ImmutableList} of {@code ImmutableItem}s. * * If the provided list is already an ImmutableList of ImmutableItems, then the list is not copied and is returned - * as-is + * as-is. If the list is null, an empty ImmutableList will be returned * - * @param list The list of items to convert - * @return An ImmutableList of ImmutableItem + * @param list The list of items to convert. + * @return An ImmutableList of ImmutableItem. If list is null, an empty list will be returned. */ + @Nonnull public ImmutableList convert(@Nullable final List list) { if (list == null) { - return null; + return ImmutableList.of(); } boolean needsCopy = false;