``` internal inline fun <reified T: BaseRes...
# announcements
x
Copy code
internal 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
?
d
replace
criteria: (query: IQuery<Bundle>) -> IQuery<Bundle>
with
criteria: IQuery<Bundle>.() -> IQuery<Bundle>
… I think. I can’t tell for sure what all your types are but
A.() -> B
is generally the notation for having
A
as the receiver in a lambda that returns
B
x
ah thanks