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

import static java.util.Objects.requireNonNull;

/**
 * <pre>{@code
 * add(<x>,0) -> <x>
 * sub(<x>,<x>) -> 0
 * add(<x>,<x>) -> mul(<x>,2)
 * }</pre>
 *
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
final class TreeRewriteRule {

	private final TreePattern _pattern;
	private final TreePattern _template;

	private TreeRewriteRule(
		final TreePattern pattern,
		final TreePattern template
	) {
		_pattern = requireNonNull(pattern);
		_template = requireNonNull(template);
	}


	public <V> void rewrite(final TreeNode<V> tree) {

		Tree<V, ?> node = null;
	}

}

@@ -791,141 +791,79 @@
 ava.
-util.Objects.requireNonNull;%0A%0A/**%0A * %3Cpre%3E%7B@code%0A * add(%3Cx%3E,0) -%3E %3Cx%3E%0A * sub(%3Cx%3E,%3Cx%3E) -%3E 0%0A * add(%3Cx%3E,%3Cx%3E) -%3E mul(%3Cx%3E,2)%0A * %7D%3C/pre%3E%0A 
+lang.String.format;%0Aimport static java.util.Objects.requireNonNull;%0A%0A/*
 *%0A *
@@ -1281,85 +1281,539 @@
 %09%7D%0A%0A
-%0A%09public %3CV%3E void rewrite(final TreeNode%3CV%3E tree
+%09TreePattern pattern() %7B%0A%09%09return _pattern;%0A%09%7D%0A%0A%09TreePattern template() %7B%0A%09%09return _template;%0A%09%7D%0A%0A%09static TreeRewriteRule of(%0A%09%09final TreePattern patter,%0A%09%09final TreePattern template%0A%09
 ) %7B%0A
-%0A
 %09%09
-Tree%3CV, ?%3E node = null
+return new TreeRewriteRule(patter, template);%0A%09%7D%0A%0A%09static TreeRewriteRule compile(final String rule) %7B%0A%09%09final String%5B%5D parts = rule.split(%22-%3E%22);%0A%09%09if (parts.length != 2) %7B%0A%09%09%09throw new IllegalArgumentException(format(%0A%09%09%09%09%22Invalid rewrite rule: %25s%22, rule%0A%09%09%09));%0A%09%09%7D%0A%0A%09%09return of(TreePattern.compile(parts%5B0%5D), TreePattern.compile(parts%5B1%5D))
 ;%0A%09%7D

Implement 'TreeRewriteRule' class.