AB
02/02/2021, 9:44 PMclass Mapper
{
// can I have a one generic method, instead of two ??
like: fun <T> MapKeyword (<U> keyword){ return T().SetId(keyword.Id).Build() }
fun MapKeywordOne(KeywordOne keywordOne) : keyWordOneBuilder
{ return keyWordOneBuilder().SetId(keywordOne.Id).Build() }
fun MapKeywordTwo(KeywordTwo keywordTwo) : keyWordTwoBuilder
{ return keyWordTwoBuilder().SetId(KeywordTwo.Id).Build() }
}
final class keyWordOneBuilder // this one is from another package and I cannot modify
{
setId(){ // implementation }
build(){ // implementation }
}
final class keyWordTwoBuilder // this one is from another package and I cannot modify
{
setId(){ // implementation }
build(){ // implementation }
}
final class KeywordOne // this one is also sealed from a different package
{
public int Id;
}
final class KeywordTwo // this one is also sealed from a different package
{
public int Id;
}
Tyler Hodgkins
02/02/2021, 10:30 PMreified
and a bit of reflection magic to create an instance, but that would rely on a no-arg constructor.AB
02/02/2021, 11:00 PMashmelev
02/03/2021, 12:28 AMTyler Hodgkins
02/03/2021, 12:44 AM