强制与具有多个参数的方法接口

coercion to interface with methods having multiple parameters

假设我有这样的界面

interface IFile {
    void writeFile(String name, byte[] bytes)
    byte[] readFile(String name)
}

如何对该接口进行强制转换? 因为到目前为止该方法不起作用并导致编译异常

def fileCoeImp = { 
    name, bytes -> new File(nane) << bytes,  
    name -> new File(name).getBytes()
} as IFile 

您需要使用地图:

def fileCoeImp = [
    writeFile : { name, bytes -> new File(name) << bytes },  
    readFile : { name -> new File(name).getBytes() }
] as IFile