VoidRepository

VoidRepository<T> is an empty implementation of GetRepository, PutRepository and DeleteRepository. Any call to these functions will result in an error being thrown.

Usage

val repository = VoidRepository<String>()
repository.get("sampleKey").onComplete(onSuccess = {}, onFailure = {
// Error is a UnsupportedOperationException
print(it)
})

Note that the example above is using the extension methods of Repository that encapsulate queries of type IdQuery<T>.

Operation Types

Any Operation can be passed to a VoidRepository<T> (and all will result with an error).

Other Implementations

Together with VoidRepository<T> there are also similar implementations for:

  • VoidGetRepository<T>: Implements GetRepository.
  • VoidPutRepository<T>: Implements PutRepository.
  • VoidDeleteRepository: Implements DeleteRepository.

Implementation Notes

Find below an example of implementation of a VoidRepository<T>:

class VoidRepository<V> : GetRepository<V>, PutRepository<V>, DeleteRepository {
override fun get(query: Query, operation: Operation): Future<V> = Future { notSupportedOperation() }
override fun getAll(query: Query, operation: Operation): Future<List<V>> = Future { notSupportedOperation() }
override fun put(query: Query, value: V?, operation: Operation): Future<V> = Future { notSupportedOperation() }
override fun putAll(query: Query, value: List<V>?, operation: Operation): Future<List<V>> = Future { notSupportedOperation() }
override fun delete(query: Query, operation: Operation): Future<Unit> = Future { notSupportedOperation() }
override fun deleteAll(query: Query, operation: Operation): Future<Unit> = Future { notSupportedOperation() }
}