0
Set<String> h = new HashSet<>(Arrays.asList("a", "b", "b", "A"));

It will set "a", "b", "A".

But, I want to do case-insensitive.

So, it will give "a", "b"

In, DTO request

public class EmpDto{
    private String empName;
    private Set<String> roles;
}

Like, If I want to get in sort order

    private Set<String> roles;

Is there any predefined implementation or custom implementation required? If custom, give me a head start

Satish Patro
  • 3,645
  • 2
  • 27
  • 53
  • There is no inbuilt method...Seems u have to take distinct of the list in lower case .. list.stream().map(String::toLowerCase).distinct().collect(Collectors.toList()) ? – user1428716 Oct 10 '19 at 17:18

1 Answers1

0

You can try this:

    Set<String> h = Stream.of("a", "b", "b", "A")
            .map(String::toLowerCase)
            .collect(Collectors.toSet());
Dino
  • 7,779
  • 12
  • 46
  • 85
Horatiu Jeflea
  • 7,256
  • 6
  • 38
  • 67