package arez.component;

import arez.Arez;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;

/**
 * Utility methods used when returning results from repositories.
 */
public final class RepositoryUtil
{
  private RepositoryUtil()
  {
  }

  /**
   * Convert specified list to results to return from query.
   * The result list will be wrapped in an unmodifiable list if {@link Arez#areRepositoryResultsModifiable()}
   * returns true, otherwise it will just return the supplied list.
   * This method should be called by repository extensions when returning list results
   * when not using {@link #asList(Stream)}.
   *
   * @param list the input list.
   * @return the output list
   */
  @Nonnull
  public static <T> List<T> toResults( @Nonnull final List<T> list )
  {
    return Arez.areRepositoryResultsModifiable() ? list : Collections.unmodifiableList( list );
  }

  /**
   * Convert specified stream to a list, wrapping as an immutable list if required.
   * This method should be called by repository extensions when returning list results.
   *
   * @param stream the input stream.
   * @return the output list
   */
  @Nonnull
  public static <T> List<T> asList( @Nonnull final Stream<T> stream )
  {
    return toResults( stream.collect( Collectors.toList() ) );
  }
}

@@ -715,24 +715,71 @@
 eam)%7D.%0A   *%0A
+   * @param %3CT%3E  the type of elements in list.%0A
    * @param 
@@ -1198,24 +1198,75 @@
 sults.%0A   *%0A
+   * @param %3CT%3E    the type of elements in stream.%0A
    * @param 

Fix javadocs