Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java list distinct by attribute

public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
    Set<Object> seen = ConcurrentHashMap.newKeySet();
    return t -> seen.add(keyExtractor.apply(t));
}

persons.stream().filter(distinctByKey(Person::getName))
Comment

PREVIOUS NEXT
Code Example
Java :: java distinct by key 
Java :: java jtable change column color 
Java :: get timezone offset java 
Java :: string length solidity 
Java :: how to resize image in java swing 
Java :: how to read file from console in java 
Java :: calendar.year java 
Java :: remove last <br/ from string java 
Java :: UTC in Java 
Java :: How to determine if a binary tree has a certain root to leaf target sum value, in Java? 
Java :: Index through 2d array 
Java :: sum of a list using for loop in dart 
Java :: android get distance between two locations kotlin 
Java :: string programs in java 
Java :: fhow to find location of java jdk 
Java :: java break 2 for loops 
Java :: map string string to java object 
Java :: enum with numbers java 
Java :: for each loop java 
Java :: start activity for result deprecate 
Java :: length of array in java 
Java :: findviewbyid in kotlin Just using id name . 
Java :: spring swagger 
Java :: okhttp3 library in android studio 
Java :: sum of array elements java 
Java :: how to import class from another file in java 
Java :: java swing set icon to JFrame 
Java :: close keyboard android 
Java :: radio button in java 
Java :: java letter alphabet index 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =