As you know, when a parameter is resolved to a CursorProvider, the runtime automatically obtains a Cursor and
injects that value instead. However, if that provider is embedded as the value of a Map or an arbitrary pojo, the
runtime can't guess that's the case and go resolve it.
Same thing applies when a component is producing a result. The runtime automatically converts returned InputStream or
PagingProvider instances into CursorProvider ones. However, if such instances are contained in some other
value, that resolution won't happen automatically either.
For these border cases, this class provides some utilities to adapt the providers into cursors and vice versa
- Since:
- 1.0
- See Also:
-
CursorProviderCursorStreamProviderCursorIteratorProvider
-
Method Summary
Modifier and TypeMethodDescriptionresolveCursor(Object value) If thevalueis aCursorProvider, a correspondingCursoris returned.resolveCursorProvider(Object value) If thevalueis a repeatable streaming resource such asInputStream,Cursor, streaming iterators, etc., then an equivalentCursorProvideris returned.resolveCursorProviders(Map<K, Object> map, boolean recursive) Inspects the values of the givenmaplooking for repeatable streaming resources such asInputStream,Cursor, streaming iterators, etc., A new equivalent map is returned, except that such values have been replaced byCursorProviderinstances.resolveCursors(Map<K, Object> map, boolean recursive) Inspects the values of the givenmaplooking for instances ofCursorProvider.
-
Method Details
-
resolveCursors
Inspects the values of the givenmaplooking for instances ofCursorProvider. A new equivalent map is returned, except that theCursorProvidervalues have been replaced by obtainedcursors. No side effect is applied on the originalmap.A best effort will be made for the returned map to be of the same class as the original one. If that's not possible (most likely because the class doesn't have an accessible default constructor), then the runtime will choose its own map implementation, but guarantying that the iterator order is respected.
If the
mapcontains a value of typeMapandrecursiveis set totrue, then thatMapvalue will also be replaced by a new map which comes from recursively applying this same method. -
resolveCursorProviders
Inspects the values of the givenmaplooking for repeatable streaming resources such asInputStream,Cursor, streaming iterators, etc., A new equivalent map is returned, except that such values have been replaced byCursorProviderinstances. No side effect is applied on the originalmap.For
Cursorvalues, the sameCursorProviderthat already owns thatCursoris used. For other streaming values, the operation's repeatable streaming strategy will be used. If that strategy doesn't apply (e.g: the operation returns aPagingProviderbut the streaming resource is anInputStream), then the system's default matching strategy will be used instead.A best effort will be made for the returned map to be of the same class as the original one. If that's not possible (most likely because the class doesn't have an accessible default constructor), then the runtime will choose its own map implementation, but guarantying that the iterator order is respected.
If the
mapcontains a value of typeMapandrecursiveis set totrue, then thatMapvalue will also be replaced by a new map which comes from recursively applying this same method.- Type Parameters:
K- the generic type of the map's keys- Parameters:
map- aMapwhich may contain streaming valuesrecursive- Whether to also use this method to replace values of typeMap- Returns:
- a new
Mapwhich streaming values may have been replaced byCursorProviderinstances, depending on the component's configuration.
-
resolveCursor
If thevalueis aCursorProvider, a correspondingCursoris returned. The samevalueis returned otherwise.- Parameters:
value- a value which may be aCursorProvider- Returns:
- a
Cursoror the input value
-
resolveCursorProvider
If thevalueis a repeatable streaming resource such asInputStream,Cursor, streaming iterators, etc., then an equivalentCursorProvideris returned. If thevalueis not a repeatable streaming resource or the owning component is configured not to use repeatable streams, then the samevalueis returned.For
Cursorvalues, the sameCursorProviderthat already owns thatCursoris used. For other streaming values, the operation's repeatable streaming strategy will be used. If that strategy doesn't apply (e.g: the operation returns aPagingProviderbut the streaming resource is anInputStream), then the system's default matching strategy will be used instead.- Parameters:
value- a value which may be a repeatable streaming resource.- Returns:
- a
CursorProvideror the same inputvalue
-