xenoterracide
07/11/2019, 5:40 PMinternal inline fun <reified T: BaseResource> find( criteria: (query: IQuery<Bundle>) -> IQuery<Bundle>): T? {
val forResource = client.search<Bundle>().forResource(T::class.java)
val entities = criteria.invoke(forResource).execute()
if ( entities.isEmpty ) {
<http://log.info|log.info>("entity {} was not found", T::class.simpleName)
return null
}
if ( entities.total > 1 ) {
<http://log.info|log.info>("too many {} found", T::class.simpleName)
return null
}
return entities.entryFirstRep.resource as? T
}
internal fun findLocation(name: String): Location? {
return find {it.where(Location.NAME.matches().value(name)) }
}
is there a method signature where I can just call where
instead of it.where
?Drew Hamilton
07/11/2019, 6:09 PMcriteria: (query: IQuery<Bundle>) -> IQuery<Bundle>
with criteria: IQuery<Bundle>.() -> IQuery<Bundle>
A.() -> B
is generally the notation for having A
as the receiver in a lambda that returns B
xenoterracide
07/11/2019, 6:41 PM