01 /*
02 * Java Genetic Algorithm Library (jenetics-2.0.2).
03 * Copyright (c) 2007-2014 Franz Wilhelmstötter
04 *
05 * Licensed under the Apache License, Version 2.0 (the "License");
06 * you may not use this file except in compliance with the License.
07 * You may obtain a copy of the License at
08 *
09 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Author:
18 * Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
19 */
20 package org.jenetics;
21
22 import java.io.Serializable;
23
24 import org.jenetics.util.Factory;
25 import org.jenetics.util.Verifiable;
26
27 /**
28 * Genes are the atoms of the <em>Jenetics</em> library. They contain the actual
29 * information (alleles) of the encoded solution.
30 *
31 * @param <A> the <a href="http://en.wikipedia.org/wiki/Allele">Allele</a> type
32 * of this gene.
33 *
34 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
35 * @since 1.0
36 * @version 2.0 — <em>$Date: 2014-04-16 $</em>
37 */
38 public interface Gene<A, G extends Gene<A, G>>
39 extends
40 Factory<G>,
41 Serializable,
42 Verifiable
43 {
44
45 /**
46 * Return the allele of this gene.
47 *
48 * @return the allele of this gene.
49 */
50 public A getAllele();
51
52 /**
53 * Return a new, random gene of the same type than this gene. For all genes
54 * returned by this method holds {@code gene.getClass() ==
55 * gene.newInstance().getClass()}.
56 */
57 @Override
58 public G newInstance();
59
60 /**
61 * Create a new gene from the given {@code value} and the gene context.
62 *
63 * @since 2.0
64 * @param value the value of the new gene.
65 * @return a new gene with the given value.
66 */
67 public G newInstance(final A value);
68
69 }
|