VoidDataSource
VoidDataSource<T>
is an empty implementation of GetDataSource
, PutDataSource
and DeleteDataSource
. Any call to these functions will result in an error being thrown.
Usage
- Kotlin
- Swift
val dataSource = VoidDataSource<String>()getDataSource.get("sampleKey").onComplete(onSuccess = {}, onFailure = { // Error is a UnsupportedOperationException print(it)})
Note that the example above is using the extension methods of DataSoruce
that encapsulate queries of type IdQuery<T>
.
Query Types
Any Query
can be passed to a VoidDataSource<T>
(and all will result with an error).
Other Implementations
Together with VoidDataSource<T>
there are also similar implementations for:
VoidGetDataSource<T>
: ImplementsGetDataSource
.VoidPutDataSource<T>
: ImplementsPutDataSource
.VoidDeleteDataSource
: ImplementsDeleteDataSource
.
Implementation Notes
Find below an example of implementation of a VoidDataSource<T>
:
- Kotlin
- Swift
class VoidDataSource<V> : GetDataSource<V>, PutDataSource<V>, DeleteDataSource { override fun get(query: Query): Future<V> = Future { throw UnsupportedOperationException() } override fun getAll(query: Query): Future<List<V>> = Future { throw UnsupportedOperationException() } override fun put(query: Query, value: V?): Future<V> = Future { throw UnsupportedOperationException() } override fun putAll(query: Query, value: List<V>?): Future<List<V>> = Future { throw UnsupportedOperationException() } override fun delete(query: Query): Future<Unit> = Future { throw UnsupportedOperationException() } override fun deleteAll(query: Query): Future<Unit> = Future { throw UnsupportedOperationException() }}