/*
 * 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.ext;

import static java.util.Objects.requireNonNull;

import java.util.Comparator;

/**
 * Multi objective fitness value.
 *
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
public class MOF<T> implements Comparable<MOF<T>> {




	@Override
	public int compareTo(final MOF<T> o) {
		return 0;
	}

	public static <T> int
	compare(final T[] a, final T[] b, final Comparator<? super T> comparator) {
		requireNonNull(comparator);
		if (a.length != b.length) {
			throw new IllegalArgumentException();
		}

		boolean adom = false;
		boolean bdom = false;

		for (int i = 0; i < a.length; ++i) {
			final int cmp = comparator.compare(a[i], b[i]);

			if (cmp > 0) {
				adom = true;
				if (bdom) {
					return 0;
				}
			} else if (cmp < 0) {
				bdom = true;
				if (adom) {
					return 0;
				}
			}
		}

		if (adom == bdom) {
			return 0;
		} else if (adom) {
			return 1;
		} else {
			return -1;
		}
	}

}

@@ -812,16 +812,41 @@
 nNull;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -1054,16 +1054,22 @@
 %0Apublic 
+final 
 class MO
@@ -1110,72 +1110,761 @@
  %7B%0A%0A
-%0A%0A%0A%09@Override%0A%09public int compareTo(final MOF%3CT%3E o) %7B%0A%09%09return 0
+%09private final T%5B%5D _fitness;%0A%09private final Comparator%3C? super T%3E _comparator;%0A%0A%09private MOF(final T%5B%5D fitness, final Comparator%3C? super T%3E comparator) %7B%0A%09%09_fitness = requireNonNull(fitness);%0A%09%09_comparator = requireNonNull(comparator);%0A%09%7D%0A%0A%09public int arity() %7B%0A%09%09return _fitness.length;%0A%09%7D%0A%0A%09public T get(final int index) %7B%0A%09%09return _fitness%5Bindex%5D;%0A%09%7D%0A%0A%09@Override%0A%09public int compareTo(final MOF%3CT%3E o) %7B%0A%09%09return compare(_fitness, o._fitness, _comparator);%0A%09%7D%0A%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09return Arrays.hashCode(_fitness);%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(final Object obj) %7B%0A%09%09return obj instanceof MOF%3C?%3E &&%0A%09%09%09Arrays.equals(((MOF)obj)._fitness, _fitness);%0A%09%7D%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09return Arrays.toString(_fitness)
 ;%0A%09%7D
@@ -2474,10 +2474,287 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09public static %3CT%3E MOF%3CT%3E%0A%09of(final T%5B%5D fitness, final Comparator%3C? super T%3E comparator) %7B%0A%09%09return new MOF%3C%3E(fitness, comparator);%0A%09%7D%0A%0A%09public static %3CT extends Comparable%3C? super T%3E%3E MOF%3CT%3E%0A%09of(final T%5B%5D fitness) %7B%0A%09%09return new MOF%3C%3E(fitness, Comparator.naturalOrder());%0A%09%7D%0A%0A
 %7D%0A

Implement pareto comparator.