package Ġcom . km orph . processor . generator Ċ Ċ import Ġcom . km orph . processor . constant . Constant . AUTO _ GENER ATE _ CLASS _ FROM _ K MOR PH _ LIBRARY Ċ import Ġcom . km orph . processor . generator . Function Spec Factory . Function Spec Type .* Ċ import Ġcom . km orph . processor . model . Class MetaData Ċ import Ġcom . squareup . kotlin po et . File Spec Ċ import Ġcom . squareup . kotlin po et . as ClassName Ċ import Ġjava . io . File Ċ Ċ class ĠK Morph Generator ( val Ġgenerated FilePath : ĠString ) Ġ{ ĊĠĠĠ Ġfun Ġgenerate ( source Class MetaData : ĠClass MetaData , Ġtarget Class MetaData : ĠClass MetaData ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfunction Spec Factory Ġ= ĠFunction Spec Factory () ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠFile Spec . builder ( source Class MetaData . class Element . as ClassName (). packageName , ĠString . format ("${ source Class MetaData . class Element . simple Name } Morph er ")) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Comment ( AUTO _ GENER ATE _ CLASS _ FROM _ K MOR PH _ LIBRARY ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. addFunction ( function Spec Factory . get Function Spec ( if Ġ( target Class MetaData . no Arg Constructor Present ) ĠM OR PH _ TO _ TARGET _ USING _ GET TER _ SET TER Ġelse ĠM OR PH _ TO _ TARGET _ USING _ CON STRUCTOR ). generate ( source Class MetaData , Ġtarget Class MetaData )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. addFunction ( function Spec Factory . get Function Spec ( if Ġ( source Class MetaData . no Arg Constructor Present ) ĠM OR PH _ TO _ SOURCE _ USING _ GET TER _ SET TER Ġelse ĠM OR PH _ TO _ SOURCE _ USING _ CON STRUCTOR ). generate ( source Class MetaData , Ġtarget Class MetaData )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġfile . writeTo ( File ( generated FilePath )) ĊĠĠĠ Ġ} Ċ } ĊĊĊĊ