My case is that i have a method that takes Collection and i have the value as a list
when i tried to add the list value into collection parameter it doesn’t work, so should i cast it ?
UPDATE:
when i tried to create:
new org.springframework.security.core.userdetails.User(
user.getEmail(), user.getPassword(), true, true, true, true,
user.getAuthorities());
where user.getAuthorities() returns an arraylist of my defined Authority object
above code gives error that the constructor is undefined, when i add collection casting it works fine.
org.springframework.security.core.userdetails
Class UserConstructor
User(java.lang.String username, java.lang.String password,
boolean enabled, boolean accountNonExpired,
boolean credentialsNonExpired, boolean accountNonLocked,
java.util.Collection<? extends GrantedAuthority> authorities)
The javadoc of the User constructor tells you that the last argument must be a
Collection<? extends GrantedAuthority>. So, you ArrayList will be accepted if it’s anArrayList<Something>, whereSomethingisGrantedAuthorityor a class which implementsGrantedAuthority.You still haven’t told us what was the exact type returned by the method
user.getAuthorities(). Do you understand Generics? Have you read the Java tutorial about generics?