converted from groovy to java