001/*
002 * Java Genetic Algorithm Library (jenetics-8.1.0).
003 * Copyright (c) 2007-2024 Franz Wilhelmstötter
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 * Author:
018 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
019 */
020package io.jenetics.ext;
021
022import io.jenetics.Chromosome;
023
024/**
025 * Chromosome for tree shaped genes.
026 *
027 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
028 * @version 6.0
029 * @since 3.9
030 */
031public interface TreeChromosome<A, G extends TreeGene<A, G>>
032        extends Chromosome<G>
033{
034
035        /**
036         * Return the root gene of this chromosome. Since the gene type is also a
037         * {@link io.jenetics.ext.util.Tree}, you are able to assign it to one.
038         * {@snippet lang="java":
039         * final Tree<A, ?> t1 = root();
040         * final Tree<?, ?> t2 = root();
041         * }
042         * This method is also an alias for {@link #gene()}, which returns the
043         * first gene of the chromosome.
044         *
045         * @see #gene()
046         *
047         * @return the root tree gene of this chromosome
048         */
049        default G root() {
050                return gene();
051        }
052
053}