<commit_before>import static java.util.Arrays.asList;

import java.util.*;

public class Mixins {
	public static void main(String[] args) {
		Predicate<String> predicate = s -> s.length() == 3;
		boolean all3Letters = predicate.matchesAll(asList("Foo", "Bar", "Baz"));
		System.out.println(all3Letters);
	}
	
	@FunctionalInterface
	public interface Predicate<T> {
		static <T> Predicate<T> alwaysTrue() {
			return t -> true;
		}

		static <T> Predicate<T> alwaysFalse() {
			return t -> false;
		}
		
		boolean matches(T instance);

		default boolean matchesAll(Collection<T> instances) {
			return instances.stream().allMatch(this::matches);
		}

		default Predicate<T> and(Predicate<T> other) {
			return it -> matches(it) && other.matches(it);
		}

		default Predicate<T> or(Predicate<T> other) {
			return it -> matches(it) || other.matches(it);
		}

		default Predicate<T> negate() {
			return it -> !matches(it);
		}
	}

}<commit_msg>a little documentation for Mixins<commit_after>import static java.util.Arrays.asList;

import java.util.*;

public class Mixins {
	public static void main(String[] args) {
		Predicate<String> predicate = s -> s.length() == 3;
		boolean all3Letters = predicate.matchesAll(asList("Foo", "Bar", "Baz"));
	}
	//interfaces can now have default methods
	//implementors only need to implement abstract methods
	//but they can also override default methods
	//this greatly reduces the "Interface+Skeleton Class" pattern
	@FunctionalInterface
	public interface Predicate<T> {
		//only this needs to be implemented
		boolean matches(T instance);

		default boolean matchesAll(Collection<T> instances) {
			return instances.stream().allMatch(this::matches);
		}

		default Predicate<T> and(Predicate<T> other) {
			return it -> matches(it) && other.matches(it);
		}

		default Predicate<T> or(Predicate<T> other) {
			return it -> matches(it) || other.matches(it);
		}
		//this can be overriden if the implementor has a more efficient/meaningful version
		default Predicate<T> negate() {
			return it -> !matches(it);
		}
		
		//interfaces can now have static methods 
		//so you no longer need an additional utility class to hold your utility functions
		static <T> Predicate<T> alwaysTrue() {
			return t -> true;
		}

		static <T> Predicate<T> alwaysFalse() {
			return t -> false;
		}
	}

}
{'fraction_non_alphanumeric': 0.12951807228915663, 'fraction_numerical': 0.0021514629948364886, 'mean_word_length': 3.967948717948718, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6838050', 'n_tokens_mistral': 811, 'n_tokens_neox': 725, 'n_words': 214}