Skip to content

Instantly share code, notes, and snippets.

@jaspersprengers jaspersprengers/entityconverter.kt Secret

Last active Feb 4, 2018
Embed
What would you like to do?
entityConverter
@FunctionalInterface
interface Converter<in E : HasDTO<out D>, out D : DTO> : (E) -> D
@Service
class PreferenceToDto : Converter<Preference, PreferenceDTO> {
override fun invoke(preference: Preference): PreferenceDTO = TODO()
}
@Autowired
lateinit var converter: PreferenceToDto
//invocation with explicit method name
val dto = converter.convert(someEntity)
//the shorthand version
val dto2 = converter(someEntity)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.