возможно ли преобразовать приведенный ниже цикл for в код Java 8?
Object[] args = pjp.getArgs();
MethodSignature methodSignature = (MethodSignature) pjp.getStaticPart()
.getSignature();
Method method = methodSignature.getMethod();
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
StringBuilder methodArgs = new StringBuilder();
for (int argIndex = 0; argIndex < args.length; argIndex++) {
for (Annotation annotation : parameterAnnotations[argIndex]) {
if ((annotation instanceof RequestParam) || (annotation instanceof PathVariable) || (annotation instanceof RequestHeader)) {
methodArgs.append(args[argIndex] + "|");
} else if ((annotation instanceof RequestBody)) {
methodArgs.append(mapper.writeValueAsString(args[argIndex]) + "|");
}
}
}
Я пытался использовать приведенный ниже код Java 8.Имя функции берется случайным образом
public void some() {
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
Arrays.stream(parameterAnnotations)
.map(f -> asd(f));
}
private Object asd(Annotation[] annotations) {
Arrays.stream(annotations)
.map(a -> change(a)); //here is problem...how i can access args[argIndex]
return null;
}