Class CollectionsUtil

java.lang.Object
arez.component.internal.CollectionsUtil

@OmitType(unless="arez.collections_properties_unmodifiable") public final class CollectionsUtil extends Object
Utility methods used when returning results from repositories.
  • Method Details

    • wrap

      @Nonnull public static <T> Collection<T> wrap(@Nonnull Collection<T> collection)
      Wrap specified parameter with unmodifiable variant if and only if Arez.areCollectionsPropertiesUnmodifiable() returns true, otherwise return the supplied list. This method is invoked by the generated code when it detects list properties and should be used by repository extensions when returning collection results.
      Type Parameters:
      T - the type of elements in collection.
      Parameters:
      collection - the input collection.
      Returns:
      the output collection.
    • wrap

      @Nonnull public static <T> Set<T> wrap(@Nonnull Set<T> set)
      Wrap specified parameter with unmodifiable set if and only if Arez.areCollectionsPropertiesUnmodifiable() returns true, otherwise return the supplied set. This method is invoked by the generated code when it detects set properties and should be used by repository extensions when returning set results.
      Type Parameters:
      T - the type of elements in set.
      Parameters:
      set - the input set.
      Returns:
      the output set.
    • wrap

      @Nonnull public static <K, V> Map<K,V> wrap(@Nonnull Map<K,V> map)
      Wrap specified parameter with unmodifiable map if and only if Arez.areCollectionsPropertiesUnmodifiable() returns true, otherwise return the supplied map. This method is invoked by the generated code when it detects map properties and should be used by repository extensions when returning map results.
      Type Parameters:
      K - the type of key elements in map.
      V - the type of value elements in map.
      Parameters:
      map - the input map.
      Returns:
      the output map.
    • wrap

      @Nonnull public static <T> List<T> wrap(@Nonnull List<T> list)
      Wrap specified list with unmodifiable list if and only if Arez.areCollectionsPropertiesUnmodifiable() returns true, otherwise return the supplied list. This method is invoked by the generated code when it detects list properties and should be used by repository extensions when returning list results.
      Type Parameters:
      T - the type of elements in collection.
      Parameters:
      list - the input collection.
      Returns:
      the output collection.
    • asList

      @Nonnull public static <T> List<T> asList(@Nonnull Stream<T> stream)
      Convert specified stream to a list, wrapping as an unmodifiable list if required. This method should be called by repository extensions when returning list results.
      Type Parameters:
      T - the type of elements in stream.
      Parameters:
      stream - the input stream.
      Returns:
      the output list