All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hypersistence.utils.hibernate.query.DistinctListTransformer Maven / Gradle / Ivy

There is a newer version: 3.8.3
Show newest version
package io.hypersistence.utils.hibernate.query;

import org.hibernate.query.ResultListTransformer;

import java.util.List;
import java.util.stream.Collectors;

/**
 * The {@link DistinctListTransformer} removes duplicates from the {@link List}
 * of elements that were transformed by the {@link org.hibernate.query.TupleTransformer}.
 * 

* This is similar to the {@code DistinctResultTransformer} that was available in Hibernate 5. * * @author Vlad Mihalcea * @since 2.21.0 */ public class DistinctListTransformer implements ResultListTransformer { public static final DistinctListTransformer INSTANCE = new DistinctListTransformer(); /** * Deduplicates the provided List. * * @param collection collections to be deduplicated * @return deduplicated List */ @Override public List transformList(List collection) { return (List) collection.stream().distinct().collect(Collectors.toList()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy