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

import java.util.List;
import java.util.function.Function;

import io.jenetics.BitGene;
import io.jenetics.IntegerGene;
import io.jenetics.engine.Codec;
import io.jenetics.util.IntRange;

import io.jenetics.ext.grammar.Cfg.Rule;
import io.jenetics.ext.grammar.Cfg.Terminal;

public final class Mappers {
	private Mappers() {
	}

	public static <T> Codec<List<Terminal<T>>, IntegerGene> of(
		final Cfg<? extends T> cfg,
		final Function<? super Rule<?>, IntRange> length,
		final Function<? super SymbolIndex, ? extends Generator<T, List<Terminal<T>>>> generator
	) {
		return new Mapper<>(cfg, length, generator);
	}

	public static <T> Codec<List<Terminal<T>>, BitGene> of(
		final Cfg<? extends T> cfg,
		final int length,
		final Function<? super SymbolIndex, ? extends Generator<T, List<Terminal<T>>>> generator
	) {
		return new BitGeneSentenceCodec<>(cfg, length, generator);
	}

	public static <T> Codec<List<Terminal<T>>, IntegerGene> of(
		final Cfg<? extends T> cfg,
		final IntRange range,
		final IntRange length,
		final Function<? super SymbolIndex, ? extends Generator<T, List<Terminal<T>>>> generator
	) {
		return new IntegerGeneSentenceCodec<>(cfg, range, length, generator);
	}

}

@@ -1140,38 +1140,60 @@
 rminal%3CT%3E%3E, 
-IntegerGene%3E o
+BitGene%3E%0A%09singleBitChromosomeMapperO
 f(%0A%09%09final C
@@ -1225,43 +1225,11 @@
 nal 
-Function%3C? super Rule%3C?%3E, IntRange%3E
+int
  len
@@ -1342,22 +1342,36 @@
 urn new 
-Mapper
+BitGeneSentenceCodec
 %3C%3E(cfg, 
@@ -1442,18 +1442,52 @@
 %3E%3E, 
-BitGene%3E o
+IntegerGene%3E%0A%09singleIntegerChromosomeMapperO
 f(%0A%09
@@ -1515,35 +1515,64 @@
 T%3E cfg,%0A%09%09final 
-int
+IntRange range,%0A%09%09final IntRange
  length,%0A%09%09final
@@ -1665,35 +1665,39 @@
  %7B%0A%09%09return new 
-Bit
+Integer
 GeneSentenceCode
@@ -1696,32 +1696,39 @@
 enceCodec%3C%3E(cfg,
+ range,
  length, generat
@@ -1792,18 +1792,47 @@
 gerGene%3E
- o
+%0A%09multiIntegerChromosomeMapperO
 f(%0A%09%09fin
@@ -1864,39 +1864,41 @@
 %09%09final 
-IntRange range,%0A%09%09final
+Function%3C? super Rule%3C?%3E,
  IntRang
@@ -1890,32 +1890,33 @@
 ule%3C?%3E, IntRange
+%3E
  length,%0A%09%09final
@@ -2021,45 +2021,20 @@
 new 
-IntegerGeneSentenceCodec%3C%3E(cfg, range
+Mapper%3C%3E(cfg
 , le
@@ -2055,10 +2055,11 @@
 r);%0A%09%7D%0A%0A
+%0A
 %7D%0A

Rename factory methods.