name.remal.gradle_plugins.merge_resources.mergers.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of merge-resources Show documentation
Show all versions of merge-resources Show documentation
Remal Gradle plugins: merge-resources
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);
};
}
}