private static MethodDefinition defineSetAndGetMethod(Class<?> aClass) { Parameter arr = arg("arr", type(aClass)); Parameter index = arg("index", type(int.class)); Class<?> componentType = aClass.getComponentType(); Parameter value = arg("value", type(componentType)); MethodDefinition methodDefinition = classDefinition.declareMethod(a(PUBLIC, STATIC), "setAndGetMethod_" + componentType.getSimpleName(), type(componentType), arr, index, value); methodDefinition.getBody() .append(arr.setElement(index, value)) .append(arr.getElement(index).ret()); return methodDefinition; } }