inline fun <reified T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String): T
Locates an object by name and casts it to the expected type T.
If an object with the given name is not found, UnknownDomainObjectException is thrown. If the object is found but cannot be cast to the expected type T, IllegalArgumentException is thrown.
UnknownDomainObjectException
- When the given object is not found.
IllegalArgumentException
- When the given object cannot be cast to the expected type.
Return
the object, never null
fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, type: KClass<T>): T
Locates an object by name and casts it to the expected type.
If an object with the given name is not found, UnknownDomainObjectException is thrown. If the object is found but cannot be cast to the expected type, IllegalArgumentException is thrown.
UnknownDomainObjectException
- When the given object is not found.
IllegalArgumentException
- When the given object cannot be cast to the expected type.
Return
the object, never null
inline fun <reified T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, configure: T.() -> Unit): T
Locates an object by name and casts it to the expected type T then configures it.
If an object with the given name is not found, UnknownDomainObjectException is thrown. If the object is found but cannot be cast to the expected type T, IllegalArgumentException is thrown.
configure
- configuration action to apply to the object before returning it
UnknownDomainObjectException
- When the given object is not found.
IllegalArgumentException
- When the given object cannot be cast to the expected type.
Return
the object, never null