From 3c6c45fe9653b53288f99c68fc6b9d28da5a48ba Mon Sep 17 00:00:00 2001 From: shreyax Date: Fri, 22 Sep 2017 14:31:05 -0400 Subject: Allow alternate GroupedList constructor to be public, but add warnings regarding the integrity of the structure to various operations. PiperOrigin-RevId: 169715233 --- .../com/google/devtools/build/lib/util/GroupedList.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/google/devtools/build/lib/util/GroupedList.java b/src/main/java/com/google/devtools/build/lib/util/GroupedList.java index 87848ffafc..8c34e470ca 100644 --- a/src/main/java/com/google/devtools/build/lib/util/GroupedList.java +++ b/src/main/java/com/google/devtools/build/lib/util/GroupedList.java @@ -49,8 +49,9 @@ public class GroupedList implements Iterable> { this.elements = new ArrayList<>(1); } - // Only for use when uncompressing a GroupedList. - private GroupedList(int size, List elements) { + // Use with caution as there are no checks in place for the integrity of the resulting object + // (no de-duping or verifying there are no nested lists). + public GroupedList(int size, List elements) { this.size = size; this.elements = new ArrayList<>(elements); } @@ -99,6 +100,8 @@ public class GroupedList implements Iterable> { return uniquifier; } + // Use with caution as there are no checks in place for the integrity of the resulting object + // (no de-duping). public void appendGroup(Collection group) { // Do a check to make sure we don't have lists here. Note that if group is empty, // Iterables.getFirst will return null, and null is not instanceof List. @@ -356,9 +359,12 @@ public class GroupedList implements Iterable> { *

If it contains a single element, then that element must not be {@code null}, and that * element is added to {@param elements}. * - *

If it contains more than one element, then an {@link ImmutableList} copy of {@param item} - * is added as the next element of {@param elements}. (This means {@param elements} may contain - * both raw objects and {@link ImmutableList}s.) + *

If it contains more than one element, then an {@link ImmutableList} copy of {@param item} is + * added as the next element of {@param elements}. (This means {@param elements} may contain both + * raw objects and {@link ImmutableList}s.) + * + *

Use with caution as there are no checks in place for the integrity of the resulting object + * (no de-duping or verifying there are no nested lists). */ private static void addItem(Collection item, List elements) { switch (item.size()) { -- cgit v1.2.3