R
R
Romanov19812020-10-12 21:35:17
Java
Romanov1981, 2020-10-12 21:35:17

Arrow function?

Hello.

Please help me get rid of the lambda expression.

@Controller
class RunAsController {

    @Autowired
    RunAsService runAsService;



    @Secured({ "ROLE_USER", "RUN_AS_REPORTER" })
    @ResponseBody
    @GetMapping("/runs")
    public String tryRunAs() {

        Authentication auth = runAsService.getCurrentUser();
        auth.getAuthorities().forEach(a -> System.out.println(a.getAuthority()));
        return "Current User Authorities inside this RunAS method only " + auth.getAuthorities().toString();

    }

}


I promise to study them soon.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2020-10-12
@Romanov1981

auth.getAuthorities().forEach(a -> System.out.println(a.getAuthority()));

something like this:
for (Authority a : auth.getAuthorities()) {
System.out.println(a.getAuthority());
}

5
5am, 2020-10-12
​​@5am

for / foreach by auth.getAuthorities() {. }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question