/*
 * 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@gmx.at)
 */
package org.jenetics.internal.util;

import static java.util.Objects.requireNonNull;

import java.time.Duration;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
 * @since 3.0
 * @version 3.0 &mdash; <em>$Date: 2014-08-06 $</em>
 */
public class TimedResult<T> {
	private final Duration _duration;
	private final T _result;

	private TimedResult(final Duration duration, final T result) {
		_duration = requireNonNull(duration);
		_result = requireNonNull(result);
	}

	public static <T> Supplier<TimedResult<T>> of(
		final Supplier<? extends T> supplier
	) {
		return () -> {
			final Timer timer = Timer.of().start();
			try {
				return new TimedResult<>(timer.getTime(), supplier.get());
			} finally {
				timer.stop();
			}
		};
	}

	public static <T, R> Function<T, TimedResult<R>> of(
		final Function<? super T, ? extends R> function
	) {
		return value -> {
			final Timer timer = Timer.of().start();
			try {
				return new TimedResult<>(timer.getTime(), function.apply(value));
			} finally {
				timer.stop();
			}
		};
	}

	public T get() {
		return _result;
	}

	public Duration getDuration() {
		return _duration;
	}

}

@@ -816,24 +816,53 @@
 reNonNull;%0A%0A
+import java.io.Serializable;%0A
 import java.
@@ -953,16 +953,98 @@
 r;%0A%0A/**%0A
+ * Container class which contains the execution result and the execution time.%0A *%0A
  * @auth
@@ -1179,9 +1179,9 @@
 08-0
-6
+7
  $%3C/
@@ -1195,16 +1195,22 @@
 %0Apublic 
+final 
 class Ti
@@ -1222,17 +1222,92 @@
 sult%3CT%3E 
-%7B
+implements Serializable %7B%0A%09private static final long serialVersionUID = 1L;%0A
 %0A%09privat
@@ -1501,24 +1501,259 @@
 esult);%0A%09%7D%0A%0A
+%09/**%0A%09 * Wraps the given supplier in a supplier which returns a %7B@code TimedResult%7D.%0A%09 *%0A%09 * @param supplier the supplier to wrap%0A%09 * @param %3CT%3E the result type%0A%09 * @return the wrapped supplier which returns a %7B@code TimedResult%7D%0A%09 */%0A
 %09public stat
@@ -2003,32 +2003,325 @@
 ;%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%0A
+%09/**%0A%09 * Wraps the given function in a function which returns a%0A%09 * %7B@code TimedResult%7D.%0A%09 *%0A%09 * @param function the function to wrap%0A%09 * @param %3CT%3E the functions parameter type%0A%09 * @param %3CR%3E the functions return type%0A%09 * @return the wrapped function which returns a %7B@code TimedResult%7D%0A%09 */%0A
 %09public static %3C
@@ -2607,46 +2607,211 @@
 %7D%0A%0A%09
-public T get() %7B%0A%09%09return _result;%0A%09%7D%0A
+/**%0A%09 * Return the execution result.%0A%09 *%0A%09 * @return the execution result.%0A%09 */%0A%09public T get() %7B%0A%09%09return _result;%0A%09%7D%0A%0A%09/**%0A%09 * Return the execution duration.%0A%09 *%0A%09 * @return the execution duration%0A%09 */
 %0A%09pu

Add javadoc. Make class serializable.