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

name.remal.gradle_plugins.merge_resources.mergers.Utils Maven / Gradle / Ivy

The newest version!
package name.remal.gradle_plugins.merge_resources.mergers;

import static lombok.AccessLevel.PRIVATE;

import java.util.LinkedHashSet;
import java.util.function.Function;
import java.util.function.Predicate;
import lombok.NoArgsConstructor;
import lombok.val;

@NoArgsConstructor(access = PRIVATE)
abstract class Utils {

    public static  E removeFirst(Iterable iterable) {
        val iterator = iterable.iterator();
        val firstElement = iterator.next();
        iterator.remove();
        return firstElement;
    }

    public static  Predicate distinctBy(Function getter) {
        val processed = new LinkedHashSet();
        return element -> {
            val value = getter.apply(element);
            return processed.add(value);
        };
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy