Java Stream with ::new to Kotlin

Viewed 1061

I'm trying to convert the following Spring Security code from Java to Kotlin.

Java:

Collection<? extends GrantedAuthority> authorities =
        Arrays.stream(claims.get(AUTHORITIES_KEY).toString().split(","))
            .map(SimpleGrantedAuthority::new)
            .collect(Collectors.toList());

Kotlin:

val authorities = Arrays.stream(claims[AUTHORITIES_KEY].toString().split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray())
        .map(SimpleGrantedAuthority())
        .collect(Collectors.toList<SimpleGrantedAuthority>())

I get a Type mismatch error (Required: Function<in String!, out (???..???)>!) on .map(SimpleGrantedAuthority()). How do I convert the above Java code to Kotlin with a ::new keyword correctly?

2 Answers
Related