Package arez.component.internal
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 Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>
Convert specified stream to a list, wrapping as an unmodifiable list if required.static <T> Collection<T>
wrap
(Collection<T> collection) Wrap specified parameter with unmodifiable variant if and only ifArez.areCollectionsPropertiesUnmodifiable()
returns true, otherwise return the supplied list.static <T> List<T>
Wrap specified list with unmodifiable list if and only ifArez.areCollectionsPropertiesUnmodifiable()
returns true, otherwise return the supplied list.static <K,
V> Map<K, V> Wrap specified parameter with unmodifiable map if and only ifArez.areCollectionsPropertiesUnmodifiable()
returns true, otherwise return the supplied map.static <T> Set<T>
Wrap specified parameter with unmodifiable set if and only ifArez.areCollectionsPropertiesUnmodifiable()
returns true, otherwise return the supplied set.
-
Method Details
-
wrap
Wrap specified parameter with unmodifiable variant if and only ifArez.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
Wrap specified parameter with unmodifiable set if and only ifArez.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
Wrap specified parameter with unmodifiable map if and only ifArez.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
Wrap specified list with unmodifiable list if and only ifArez.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
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
-