/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
 */
package io.jenetics.internal.util;

import static java.util.Objects.requireNonNull;

import java.util.Spliterator;
import java.util.function.Predicate;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
public interface LimitSpliterator<T> extends Spliterator<T> {

	public static final Predicate<?> TRUE = a -> true;

	@SuppressWarnings("unchecked")
	public static <T> Predicate<T> TRUE() {
		return (Predicate<T>)TRUE;
	}

	public LimitSpliterator<T> limit(final Predicate<? super T> proceed);

	public static <T> Predicate<? super T> and(
		final Predicate<? super T> a,
		final Predicate<? super T> b
	) {
		requireNonNull(a);
		requireNonNull(b);

		final Predicate<? super T> result;
		if (a == TRUE && b == TRUE) {
			result = TRUE();
		} else if (a == TRUE) {
			result = b;
		} else if (b == TRUE) {
			result = a;
		} else {
			result = r -> a.test(r) & b.test(r);
		}

		return result;
	}

}

@@ -894,16 +894,169 @@
 e;%0A%0A/**%0A
+ * Extends the %7B@link Spliterator%7D interface by an additional%0A * %7B@link #limit(Predicate)%7D method which takes a predicate for limiting the%0A * stream.%0A *%0A
  * @auth
@@ -1249,16 +1249,74 @@
 r%3CT%3E %7B%0A%0A
+%09/**%0A%09 * This predicate returns always %7B@code true%7D.%0A%09 */%0A
 %09public 
@@ -1338,17 +1338,22 @@
 edicate%3C
-?
+Object
 %3E TRUE =
@@ -1370,112 +1370,782 @@
 ;%0A%0A%09
-@SuppressWarnings(%22unchecked%22)%0A%09public static %3CT%3E Predicate%3CT%3E TRUE() %7B%0A%09%09return (Predicate%3CT%3E)TRUE;%0A%09%7D%0A
+/**%0A%09 * Return a %3Cem%3Etrue%3C/em%3E predicate for the type %7B@code T%7D.%0A%09 *%0A%09 * @param %3CT%3E the predicate parameter type%0A%09 * @return a predicate which always returns %7B@code true%7D%0A%09 */%0A%09@SuppressWarnings(%22unchecked%22)%0A%09public static %3CT%3E Predicate%3CT%3E TRUE() %7B%0A%09%09return (Predicate%3CT%3E)TRUE;%0A%09%7D%0A%0A%09/**%0A%09 * Returns, if this stream is ordered, a stream consisting of the longest%0A%09 * prefix of elements taken from this stream that match the given predicate.%0A%09 * Otherwise returns, if this stream is unordered, a stream consisting of a%0A%09 * subset of elements taken from this stream that match the given predicate.%0A%09 *%0A%09 * @param proceed a non-interfering, stateless predicate to apply to elements%0A%09 *        to determine the longest prefix of elements%0A%09 * @return the new evolution stream%0A%09 */
 %0A%09pu

Add Javadoc.