extract java closure folding into a separate class with smaller methods