diff --git a/buildSrc/src/main/java/io/jenetics/gradle/Colorizer.java b/buildSrc/src/main/java/io/jenetics/gradle/Colorizer.java index 8cf573cad7..c9ca10570c 100644 --- a/buildSrc/src/main/java/io/jenetics/gradle/Colorizer.java +++ b/buildSrc/src/main/java/io/jenetics/gradle/Colorizer.java @@ -47,10 +47,10 @@ public final class Colorizer extends SimpleFileVisitor { private static final Charset CHARSET = UTF_8; - // Original start tag:
{@code
+	// Original start tag: {@snippet lang="java":
 	private static final String START_TAG = "
";
 
-	// Original end tag: }
+ // Original end tag: } private static final String END_TAG = "
"; private File _baseDir; diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/MLEvolutionStrategy.java b/jenetics.ext/src/main/java/io/jenetics/ext/MLEvolutionStrategy.java index 708e26d94a..9def6989c7 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/MLEvolutionStrategy.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/MLEvolutionStrategy.java @@ -31,21 +31,21 @@ /** * Setup for a (μ, λ)-Evolution Strategy. Applying this setup is done in the * following way. - *
{@code
+ * {@snippet lang="java":
  * final var engine = Engine.builder(problem)
  *     .setup(new MLEvolutionStrategy<>(μ, λ, p)
  *     .build();
- * }
+ * } * * And is equivalent to the following builder setup. - *
{@code
+ * {@snippet lang="java":
  * final var engine = Engine.builder(problem)
  *     .populationSize(λ)
  *     .survivorsSize(0)
  *     .offspringSelector(new TruncationSelector<>(μ))
  *     .alterers(new Mutator<>(p))
  *     .build();
- * }
+ * } * * @param the gene type * @param the fitness result type diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/MpLEvolutionStrategy.java b/jenetics.ext/src/main/java/io/jenetics/ext/MpLEvolutionStrategy.java index 6927d0a1c9..3818a4c32a 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/MpLEvolutionStrategy.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/MpLEvolutionStrategy.java @@ -31,21 +31,21 @@ /** * Setup for a (μ + λ)-Evolution Strategy. Applying this setup is done in the * following way. - *
{@code
+ * {@snippet lang="java":
  * final var engine = Engine.builder(problem)
  *     .setup(new MpLEvolutionStrategy<>(μ, λ, p)
  *     .build();
- * }
+ * } * * And is equivalent to the following builder setup. - *
{@code
+ * {@snippet lang="java":
  * final var engine = Engine.builder(problem)
  *     .populationSize(λ)
  *     .survivorsSize(μ)
  *     .offspringSelector(new TruncationSelector<>(μ))
  *     .alterers(new Mutator<>(p))
  *     .build();
- * }
+ * } * * @param the gene type * @param the fitness result type diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/TreeChromosome.java b/jenetics.ext/src/main/java/io/jenetics/ext/TreeChromosome.java index ce1f0ac21d..5776868952 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/TreeChromosome.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/TreeChromosome.java @@ -35,10 +35,10 @@ public interface TreeChromosome> /** * Return the root gene of this chromosome. Since the gene type is also a * {@link io.jenetics.ext.util.Tree}, you are able to assign it to one. - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree t1 = root();
 	 * final Tree t2 = root();
-	 * }
+ * } * This method is also an alias for {@link #gene()}, which returns the * first gene of the chromosome. * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/WeaselMutator.java b/jenetics.ext/src/main/java/io/jenetics/ext/WeaselMutator.java index 634576a2c2..a5fddec4e0 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/WeaselMutator.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/WeaselMutator.java @@ -44,7 +44,7 @@ * genotype in the population with the given mutation probability. *

* {@link io.jenetics.engine.Engine} setup for the Weasel program: - *
{@code
+ * {@snippet lang="java":
  * final Engine engine = Engine.builder(problem)
  *      // Set the 'WeaselSelector'.
  *     .selector(new WeaselSelector<>())
@@ -53,7 +53,7 @@
  *      // Set the 'WeaselMutator'.
  *     .alterers(new WeaselMutator<>(0.05))
  *     .build();
- * }
+ * } * * @see Weasel program * @see WeaselSelector diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/WeaselProgram.java b/jenetics.ext/src/main/java/io/jenetics/ext/WeaselProgram.java index 2c7d2fe960..efadba9ea7 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/WeaselProgram.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/WeaselProgram.java @@ -29,11 +29,11 @@ * Weasel program * algorithm. * - *
{@code
+ * {@snippet lang="java":
  * final Engine engine = Engine.builder(problem)
  *     .setup(new WeaselProgram<>())
  *     .build();
- * }
+ * } * * @see WeaselSelector * @see WeaselMutator diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/WeaselSelector.java b/jenetics.ext/src/main/java/io/jenetics/ext/WeaselSelector.java index d9f0a04a40..f3b31dde5b 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/WeaselSelector.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/WeaselSelector.java @@ -42,7 +42,7 @@ * instances of the best {@link Phenotype}. *

* {@link io.jenetics.engine.Engine} setup for the Weasel program: - *
{@code
+ * {@snippet lang="java":
  * final Engine engine = Engine.builder(problem)
  *      // Set the 'WeaselSelector'.
  *     .selector(new WeaselSelector<>())
@@ -51,7 +51,7 @@
  *      // Set the 'WeaselMutator'.
  *     .alterers(new WeaselMutator<>(0.05))
  *     .build();
- * }
+ * } * * @see Weasel program * @see WeaselMutator diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/engine/ConcatEngine.java b/jenetics.ext/src/main/java/io/jenetics/ext/engine/ConcatEngine.java index b142157016..21c1f6126e 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/engine/ConcatEngine.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/engine/ConcatEngine.java @@ -61,7 +61,7 @@ * Concatenating evolution engines might be useful, if you want to explore your * search space with random search first and then start the real GA * search. - *
{@code
+ * {@snippet lang="java":
  *  final Problem problem = Problem.of(
  *      v -> Math.sin(v[0])*Math.cos(v[1]),
  *      Codecs.ofVector(DoubleRange.of(0, 2*Math.PI), 2)
@@ -90,7 +90,7 @@
  *
  *  System.out.println(result + ": " +
  *          problem.fitness().apply(problem.codec().decode(result)));
- * }
+ * } * * An essential part, when concatenating evolution engines, is to make sure your * engines are creating limited evolution streams. This is what diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/engine/CyclicEngine.java b/jenetics.ext/src/main/java/io/jenetics/ext/engine/CyclicEngine.java index 2cb984807f..b39502e426 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/engine/CyclicEngine.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/engine/CyclicEngine.java @@ -57,7 +57,7 @@ * The {@code CyclicEngine} allows to do a broad search-fine search-cycle * as long as you want. * - *
{@code
+ * {@snippet lang="java":
  *  final Problem problem = Problem.of(
  *      v -> Math.sin(v[0])*Math.cos(v[1]),
  *      Codecs.ofVector(DoubleRange.of(0, 2*Math.PI), 2)
@@ -87,7 +87,7 @@
  *
  *  System.out.println(result + ": " +
  *      problem.fitness().apply(problem.codec().decode(result)));
- * }
+ * } * * When using a {@code CyclicEnginePool}, you have to limit the final evolution * stream, additionally to the defined limits on the used partial engines. diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Bnf.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Bnf.java index fc08b26393..33a45f110a 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Bnf.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Bnf.java @@ -32,7 +32,7 @@ * grammars in * BNF * format. - *
{@code
+ * {@snippet lang="java":
  * final Cfg grammar = Bnf.parse("""
  *      ::=  |  | '('    ')'
  *        ::= + | - | * | /
@@ -40,7 +40,7 @@
  *       ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  *     """
  * );
- * }
+ * } * * @author Franz Wilhelmstötter * @since 7.1 @@ -68,12 +68,12 @@ static boolean isIdChar(final char c) { * Parses the given BNF {@code grammar} string to a {@link Cfg} object. The * following example shows the grammar of a simple arithmetic expression. * - *
{@code
+	 * {@snippet lang="java":
 	 *  ::=  |  | '('    ')'
 	 *    ::= + | - | * | /
 	 *   ::= x | y
 	 *   ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
-	 * }
+ * } * * @param grammar the BNF {@code grammar} string * @return the parsed {@code BNF} object diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfParser.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfParser.java index 5ffd9fe6c8..bb34ab9cb7 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfParser.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfParser.java @@ -43,7 +43,7 @@ /** * Parser for BNF grammars. * - *
{@code
+ * {@snippet lang="java":
  * rulelist: rule_* EOF;
  * rule: lhs ASSIGN rhs;
  * lhs: id;
@@ -54,7 +54,7 @@
  * text: STRING | QUOTED_STRING;
  * id: LT ruleid GT;
  * ruleid: ID;
- * }
+ * } * * The BNF object is build from the following classes. *
    diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfTokenizer.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfTokenizer.java index e13526420b..f335e89b28 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfTokenizer.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/BnfTokenizer.java @@ -38,7 +38,7 @@ /** * Tokenizer for BNF grammars. * - *
    {@code
    + * {@snippet lang="java":
      * ASSIGN: '::=';
      * BAR: '|';
      * GT: '>';
    @@ -46,7 +46,7 @@
      * ID: ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'-')+;
      * STRING: ( '%s' | '%i' )? '"' ( ~ '"' )* '"';
      * WS: [ \r\n\t] -> skip;
    - * }
    + * } * * @author Franz Wilhelmstötter * @since 7.1 diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Cfg.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Cfg.java index 96bc49a552..f53f871129 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Cfg.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Cfg.java @@ -68,7 +68,7 @@ *
* * You can easily create a Cfg object from a given BNF grammar. - *
{@code
+ * {@snippet lang="java":
  * final Cfg grammar = Bnf.parse("""
  *      ::=  |  | '('    ')'
  *        ::= + | - | * | /
@@ -76,10 +76,10 @@
  *       ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  *     """
  * );
- * }
+ * } * * It is also possible to create the grammar above programmatically. - *
{@code
+ * {@snippet lang="java":
  * final Cfg grammar = Cfg.of(
  *     R("expr",
  *         E(NT("num")),
@@ -94,7 +94,7 @@
  *         E(T("8")), E(T("9"))
  *     )
  * );
- * }
+ * } * * @see Bnf#parse(String) * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Codons.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Codons.java index fb9e14284b..bbc1d42976 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Codons.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Codons.java @@ -38,7 +38,7 @@ * indexes are needed, the values are read from the beginning again. You have * the possibility to create a {@code Codons} object from different chromosome * types. - *
{@code
+ * {@snippet lang="java":
  * // Create 'classic' codons from a bit-chromosome, where
  * // the genes are split into 8-bit junks and converted
  * // into unsigned int values.
@@ -47,7 +47,7 @@
  * // Creating a codons object from an integer chromosome.
  * final var ich = IntegerChromosome.of(IntRange.of(0, 256), 1_000);
  * final var codons = Codons.ofIntegerGenes(ich);
- * }
+ * } * * @author Franz Wilhelmstötter * @since 7.1 @@ -85,9 +85,9 @@ public int next(final Rule rule, final int bound) { * Creates a new, classical codons object from the given bit-genes. * The genes is split into 8-bit chunks and converted into an unsigned * {@code int[]} array. - *
{@code
+	 * {@snippet lang="java":
 	 * final Codons codons = Codons.ofBitGenes(BitChromosome.of(10_000));
-	 * }
+ * } * * @param genes the genes used for creating the codon object * @return a new codons object @@ -123,10 +123,10 @@ static byte[] toByteArray(final BaseSeq genes) { /** * Creates a new codons object from the given int-genes. * - *
{@code
+	 * {@snippet lang="java":
 	 * final var chromosome = IntegerChromosome.of(IntRange.of(0, 256), 1_000);
 	 * final var codons = Codons.ofIntegerGenes(chromosome);
-	 * }
+ * } * * @param genes the genes used for creating the codon object * @return a new codons object diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/DerivationTreeGenerator.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/DerivationTreeGenerator.java index d7033a0f7e..cda8c404bc 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/DerivationTreeGenerator.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/DerivationTreeGenerator.java @@ -31,7 +31,7 @@ /** * Standard implementation of a derivation-tree generator. The following code * snippet lets you generate a derivation tree from a given grammar. - *
{@code
+ * {@snippet lang="java":
  * final Cfg cfg = Bnf.parse("""
  *      ::= (    ) |  |  |   ( ,  )
  *       ::= FUN1 | FUN2
@@ -48,7 +48,7 @@
  *     1_000
  * );
  * final Tree, ?> tree = generator.generate(cfg);
- * }
+ * } * * @see SentenceGenerator * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Mappers.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Mappers.java index bdb8fb1ef2..730dbcacd1 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Mappers.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/Mappers.java @@ -35,14 +35,14 @@ * This class defines factories for different CFG ↔ Chromosome mappings * (encodings). The classical mapping codec, with a bit-chromosome can be created * in the following way. - *
{@code
+ * {@snippet lang="java":
  * final Cfg cfg = ...;
  * final Codec>, BitGene> codec = singleBitChromosomeMapper(
  *     cfg,
  *     1000,
  *     index -> new SentenceGenerator<>(index, 1000)
  * );
- * }
+ * } * This codec creates a mapping for the given grammar {@code cfg} and uses * bit-chromosomes with length {@code 1000}. The result of the mapping will be a * list of terminal symbols which has been created by the given @@ -67,14 +67,14 @@ private Mappers() { * 8-bit junks, as described in * Grammatical Evolution by Michael O’Neill and Conor Ryan. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Cfg cfg = ...;
 	 * final Codec>, BitGene> codec = singleBitChromosomeMapper(
 	 *     cfg,
 	 *     1000,
 	 *     index -> new SentenceGenerator<>(index, 1000)
 	 * );
-	 * }
+ * } * * @see #singleIntegerChromosomeMapper(Cfg, IntRange, IntRange, Function) * @@ -105,7 +105,7 @@ private Mappers() { * The only difference is that the codons are encoded directly, via an * integer-chromosome, so that no gene split is necessary. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Cfg cfg = ...;
 	 * final Codec>, IntegerGene> codec = singleIntegerChromosomeMapper(
 	 *     cfg,
@@ -113,7 +113,7 @@ private Mappers() {
 	 *     IntRange.of(100),   // Length (range) ot the chromosome.
 	 *     index -> new SentenceGenerator<>(index, 1000)
 	 * );
-	 * }
+ * } * * @param cfg the encoding grammar * @param range the value range of the integer genes @@ -144,7 +144,7 @@ private Mappers() { * The only difference is that the codons are encoded directly, via an * integer-chromosome, so that no gene split is necessary. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Cfg cfg = ...;
 	 * final Codec>, IntegerGene> codec = singleIntegerChromosomeMapper(
 	 *     cfg,
@@ -152,7 +152,7 @@ private Mappers() {
 	 *     100,                 // Length (range) ot the chromosome.
 	 *     index -> new SentenceGenerator<>(index, 1000)
 	 * );
-	 * }
+ * } * * @param cfg the encoding grammar * @param range the value range of the integer genes @@ -182,28 +182,28 @@ private Mappers() { * every rule. The length of the chromosome is defined as a function of the * encoded rules. This means that the following CFG, * - *
{@code
+	 * {@snippet lang="java":
 	 *                       (0)            (1)
 	 * (0)  ::= () | 
 	 *               (0) (1) (2) (3)
 	 * (1)    ::= + | - | * | /
 	 *               (0) (1) (2) (3) (4)
 	 * (2)   ::= x | 1 | 2 | 3 | 4
-	 * }
+ * } * * will be represented by the following {@link Genotype} - *
{@code
+	 * {@snippet lang="java":
 	 * Genotype.of(
 	 *     IntegerChromosome.of(IntRange.of(0, 2), length.apply(cfg.rules().get(0))),
 	 *     IntegerChromosome.of(IntRange.of(0, 4), length.apply(cfg.rules().get(1))),
 	 *     IntegerChromosome.of(IntRange.of(0, 5), length.apply(cfg.rules().get(2)))
 	 * )
-	 * }
+ * } * * The {@code length} function lets you defining the number of codons as * function of the rule the chromosome is encoding. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Cfg cfg = Bnf.parse(...);
 	 * final Codec>, IntegerGene> codec = multiIntegerChromosomeMapper(
 	 *     cfg,
@@ -214,7 +214,7 @@ private Mappers() {
 	 *     // with a maximal sentence length of 500.
 	 *     index -> new SentenceGenerator<>(index, 500)
 	 * );
-	 * }
+ * } * * @param cfg the encoding grammar * @param length the length of the chromosome which is used for selecting diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/MultiIntegerChromosomeMapper.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/MultiIntegerChromosomeMapper.java index 06b774e4dd..24ef9c0eb6 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/MultiIntegerChromosomeMapper.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/MultiIntegerChromosomeMapper.java @@ -43,28 +43,28 @@ * every rule. The length of the chromosome is defined as a function of the * encoded rules. This means that the following CFG, * - *
{@code
+ * {@snippet lang="java":
  *                       (0)            (1)
  * (0)  ::= () | 
  *               (0) (1) (2) (3)
  * (1)    ::= + | - | * | /
  *               (0) (1) (2) (3) (4)
  * (2)   ::= x | 1 | 2 | 3 | 4
- * }
+ * } * * will be represented by the following {@link Genotype} - *
{@code
+ * {@snippet lang="java":
  * Genotype.of(
  *     IntegerChromosome.of(IntRange.of(0, 2), length.apply(cfg.rules().get(0))),
  *     IntegerChromosome.of(IntRange.of(0, 4), length.apply(cfg.rules().get(1))),
  *     IntegerChromosome.of(IntRange.of(0, 5), length.apply(cfg.rules().get(2)))
  * )
- * }
+ * } * * The {@code length} function lets you defining the number of codons as * function of the rule the chromosome is encoding. * - *
{@code
+ * {@snippet lang="java":
  * final Cfg cfg = Bnf.parse(...);
  * final Codec>, IntegerGene> codec = new Mapper<>(
  *     cfg,
@@ -75,7 +75,7 @@
  *     // with a maximal sentence length of 5,000.
  *     index -> new SentenceGenerator<>(index, 5_000)
  * );
- * }
+ * } * * @param the terminal token type of the grammar * @param the result type of the mapper diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/SentenceGenerator.java b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/SentenceGenerator.java index 791b2abd3f..7d37705217 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/grammar/SentenceGenerator.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/grammar/SentenceGenerator.java @@ -38,7 +38,7 @@ *

* The following code snippet shows how to create a random sentence from a * given grammar: - *

{@code
+ * {@snippet lang="java":
  * final Cfg cfg = Bnf.parse("""
  *      ::= (    ) |  |  |   ( ,  )
  *       ::= FUN1 | FUN2
@@ -60,9 +60,9 @@
  *     .collect(Collectors.joining());
  *
  * System.out.println(string);
- * }
+ * } * Some sample output: - *
{@code
+ * {@snippet lang="java":
  * > ((x-FUN1(5,5))+8)
  * > (FUN2(y,5)-FUN2(0,x))
  * > x
@@ -71,7 +71,7 @@
  * > FUN2(y,FUN2((FUN1(5,FUN1(y,2))*9),y))
  * > ((FUN1(x,5)*9)*(x/(y*FUN2(x,y))))
  * > (9-(y*(x+x)))
- * > }
+ * > } * * @see DerivationTreeGenerator * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/internal/util/FormulaParser.java b/jenetics.ext/src/main/java/io/jenetics/ext/internal/util/FormulaParser.java index 46a526fad1..a39d47c05f 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/internal/util/FormulaParser.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/internal/util/FormulaParser.java @@ -76,7 +76,7 @@ * grammar, where the output is already a list of tokens (aka sentence). The * following example parser can be used to parse arithmetic expressions. * - *
{@code
+ * {@snippet lang="java":
  * final FormulaParser parser = FormulaParser.builder()
  *     // Structural tokens.
  *     .lparen("(")
@@ -91,17 +91,17 @@
  *     .identifiers("x", "y", "z")
  *     .functions("pow", "sin", "cos")
  *     .build();
- * }
+ * } * This parser allows you to parse the following token list - *
{@code
+ * {@snippet lang="java":
  * final List tokens = List.of(
  *     "x", "*", "x", "+", "sin", "(", "z", ")", "-", "cos", "(", "x",
  *     ")", "+", "y", "/", "z", "-", "pow", "(", "z", ",", "x", ")"
  * );
  * final Tree tree = parser.parse(tokens);
- * }
+ * } * which will result in the following parsed tree: - *
{@code
+ * {@snippet lang="java":
  * "-"
  * ├── "+"
  * │   ├── "-"
@@ -119,7 +119,7 @@
  * └── "pow"
  *     ├── "z"
  *     └── "x"
- * }
+ * } * Note that the generated (parsed) tree is of type {@code Tree}. To * evaluate this tree, additional steps are necessary. If you want to * create an executable tree, you have to use the @@ -128,7 +128,7 @@ * The following code snippet shows how to create an executable AST * from a token list. The {@code MathExpr} class in the {@code io.jenetics.prog} * module uses a similar {@link TokenConverter}. - *
{@code
+ * {@snippet lang="java":
  * final Tree, ?> tree = formula.parse(
  *     tokens,
  *     (token, type) -> switch (token) {
@@ -144,7 +144,7 @@
  *             : throw new IllegalArgumentException("Unknown token: " + token);
  *     }
  * );
- * }
+ * } * * @param the token type used as input for the parser * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementComparator.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementComparator.java index 4a1941c17f..e1dc4aedbc 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementComparator.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementComparator.java @@ -26,10 +26,10 @@ * Defines the order of two elements of a given vector type {@code V}. * The following example creates an {@code ElementComparator} function for a * {@code double[] array}: - *
{@code
+ * {@snippet lang="java":
  * final ElementComparator comp =
  *     (u, v, i) -> Double.compare(u[i], v[i]);
- * }
+ * } * * @param the vector type * @@ -43,10 +43,10 @@ public interface ElementComparator { /** * Compares the components of {@code a} and {@code b} at the given * {@code index}. E.g. - *
{@code
+	 * {@snippet lang="java":
 	 * final ElementComparator comp =
 	 *     (u, v, i) -> Double.compare(u[i], v[i]);
-	 * }
+ * } * * @param u the first vector * @param v the second vector diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementDistance.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementDistance.java index e9e8a7220c..8a35d1e990 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementDistance.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/ElementDistance.java @@ -26,9 +26,9 @@ * Defines the distance of two elements of a given vector type {@code V}. * The following example creates an {@code ElementDistance} function for a * {@code double[] array}: - *
{@code
+ * {@snippet lang="java":
  * final ElementDistance dist = (u, v, i) -> u[i] - v[i];
- * }
+ * } * * @param the vector type * @@ -42,9 +42,9 @@ public interface ElementDistance { /** * Calculates the distance of two vector elements at the given {@code index}. * E.g. - *
{@code
+	 * {@snippet lang="java":
 	 * final ElementDistance dist = (u, v, i) -> u[i] - v[i];
-	 * }
+ * } * * @param u the first vector * @param v the second vector diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/MOEA.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/MOEA.java index 684d20cf83..56253d93c9 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/MOEA.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/MOEA.java @@ -39,7 +39,7 @@ * Collectors for collecting final pareto-set for multi-objective * optimization. * - *
{@code
+ * {@snippet lang="java":
  *  final Problem> problem = Problem.of(
  *      v -> Vec.of(v[0]*cos(v[1]), v[0]*sin(v[1])),
  *      Codecs.ofVector(
@@ -59,7 +59,7 @@
  *  final ISeq>> result = engine.stream()
  *      .limit(Limits.byFixedGeneration(50))
  *      .collect(MOEA.toParetoSet());
- * }
+ * } * * * @author Franz Wilhelmstötter diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/NSGA2Selector.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/NSGA2Selector.java index f025a30d19..1abc8bc4d4 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/NSGA2Selector.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/NSGA2Selector.java @@ -67,14 +67,14 @@ public class NSGA2Selector< * Creates a new {@code NSGA2Selector} with the functions needed for * handling the multi-objective result type {@code C}. For the {@link Vec} * classes, a selector is created like in the following example: - *
{@code
+	 * {@snippet lang="java":
 	 * new NSGA2Selector<>(
 	 *     Vec::dominance,
 	 *     Vec::compare,
 	 *     Vec::distance,
 	 *     Vec::length
 	 * );
-	 * }
+ * } * * @see #ofVec() * @@ -140,14 +140,14 @@ private static int[] init(final int[] indexes) { /** * Return a new selector for the given result type {@code V}. This method is * a shortcut for - *
{@code
+	 * {@snippet lang="java":
 	 * new NSGA2Selector<>(
 	 *     Vec::dominance,
 	 *     Vec::compare,
 	 *     Vec::distance,
 	 *     Vec::length
 	 * );
-	 * }
+ * } * * @param the gene type * @param the array type, e.g. {@code double[]} diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/ParetoFront.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/ParetoFront.java index ba4b8f4af2..d680e99dd9 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/ParetoFront.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/ParetoFront.java @@ -46,22 +46,22 @@ * is deterministic. *

* You can create a new {@code ParetoFront} for {@link Vec} objects - *

{@code
+ * {@snippet lang="java":
  * final ParetoFront> front = new ParetoFront<>(Vec::dominance);
  * front.add(Vec.of(1.0, 2.0));
  * front.add(Vec.of(1.1, 2.5));
  * front.add(Vec.of(0.9, 2.1));
  * front.add(Vec.of(0.0, 2.9));
- * }
+ * } * * or directly for {@code double[]} array objects - *
{@code
+ * {@snippet lang="java":
  * final ParetoFront front = new ParetoFront<>(Pareto::dominance);
  * front.add(new double[]{1.0, 2.0});
  * front.add(new double[]{1.1, 2.5});
  * front.add(new double[]{0.9, 2.1});
  * front.add(new double[]{0.0, 2.9});
- * }
+ * } * * You only have to specify the * Pareto dominance/efficiency measure. @@ -184,10 +184,10 @@ public ParetoFront merge(final ParetoFront elements) { * sorted according to its crowding distance, and the elements which have * smaller distance to its neighbors are removed first. * - *
{@code
+	 * {@snippet lang="java":
 	 * final ParetoFront> front = new ParetoFront<>(Vec::dominance);
 	 * front.trim(10, Vec::compare, Vec::distance, Vec::length);
-	 * }
+ * } * The example above reduces the given front to 10 elements. * * @param size the number of front elements after the trim. If diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/UFTournamentSelector.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/UFTournamentSelector.java index 8ddd53b03f..a750963b48 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/UFTournamentSelector.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/UFTournamentSelector.java @@ -74,14 +74,14 @@ public class UFTournamentSelector< * Creates a new {@code UFTournamentSelector} with the functions needed for * handling the multi-objective result type {@code C}. For the {@link Vec} * classes, a selector is created like in the following example: - *
{@code
+	 * {@snippet lang="java":
 	 * new UFTournamentSelector<>(
 	 *     Vec::dominance,
 	 *     Vec::compare,
 	 *     Vec::distance,
 	 *     Vec::length
 	 * );
-	 * }
+ * } * * @see #ofVec() * @@ -155,14 +155,14 @@ public ISeq> select( /** * Return a new selector for the given result type {@code V}. This method is * a shortcut for - *
{@code
+	 * {@snippet lang="java":
 	 * new UFTournamentSelector<>(
 	 *     Vec::dominance,
 	 *     Vec::compare,
 	 *     Vec::distance,
 	 *     Vec::length
 	 * );
-	 * }
+ * } * * @param the gene type * @param the array type, e.g. {@code double[]} diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/Vec.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/Vec.java index d826e13154..b2e71c0d63 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/Vec.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/Vec.java @@ -29,10 +29,10 @@ * allows you to create {@code Vec} instance from a given {@code int[]}, * {@code long[]} or {@code double[]} array. * - *
{@code
+ * {@snippet lang="java":
  * final Vec point2D = Vec.of(0.1, 5.4);
  * final Vec point3D = Vec.of(1, 2, 3);
- * }
+ * } * * The underlying array is just wrapped and not copied. This * means you can change the values of the {@code Vec} once it is created, diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/moea/VecFactory.java b/jenetics.ext/src/main/java/io/jenetics/ext/moea/VecFactory.java index b3151c39f7..0d43b5dc16 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/moea/VecFactory.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/moea/VecFactory.java @@ -31,7 +31,7 @@ *

* As the following example shows, only one {@code VecFactory} instance should * be used for creating the vectors for a given multi-objective problem. - *

{@code
+ * {@snippet lang="java":
  * private static final VecFactory FACTORY = VecFactory.ofDoubleVec(
  *     Optimize.MAXIMUM,
  *     Optimize.MINIMUM,
@@ -45,7 +45,7 @@
  *     // ...
  *     return FACTORY.newVec(result);
  * }
- * }
+ * } * In the example above, the first dimension of the created vector is maximized, * the following two are minimized, and the last vector component is again * maximized. diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TRS.java b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TRS.java index bbfe3e34e6..1527d47d3e 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TRS.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TRS.java @@ -41,7 +41,7 @@ /** * This class represents a Tree Rewrite System, which consists of a set of * Tree Rewrite Rules. - *
{@code
+ * {@snippet lang="java":
  * final TRS trs = TRS.parse(
  *     "add(0,$x) -> $x",
  *     "add(S($x),$y) -> S(add($x,$y))",
@@ -53,7 +53,7 @@
  * final TreeNode tree = TreeNode.parse("add(S(0),S(mul(S(0),S(S(0)))))");
  * trs.rewrite(tree);
  * assert tree.equals(TreeNode.parse("S(S(S(S(0))))"));
- * }
+ * } * * @see TreeRewriteRule * @see TRS diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatchResult.java b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatchResult.java index 7d725bfa35..2b74dd8142 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatchResult.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatchResult.java @@ -31,12 +31,12 @@ * The result of a tree match operation. It contains the matching tree and the * tree variables which matches the matching tree. * - *
{@code
+ * {@snippet lang="java":
  * final Tree tree = ...;
  * final TreePattern pattern = ...;
  * final Optional> result = pattern.match(tree);
  * result.ifPresent(r -> {assert r.tree() == tree;});
- * }
+ * } * * @see TreePattern#match(Tree) * @@ -62,12 +62,12 @@ private TreeMatchResult( * argument of the {@link TreePattern#match(Tree)} call, in the case of a * match. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree tree = ...;
 	 * final TreePattern pattern = ...;
 	 * final Optional> result = pattern.match(tree);
 	 * result.ifPresent(r -> {assert r.tree() == tree;});
-	 * }
+ * } * * @return node (tree), which has been matched by some pattern */ diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatcher.java b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatcher.java index 2704ad271b..6d6e356fe8 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatcher.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreeMatcher.java @@ -29,7 +29,7 @@ * Implementation of a pattern-based tree matcher. It allows you to iterate over * all matches of a tree for a given pattern. * - *
{@code
+ * {@snippet lang="java":
  * final TreePattern pattern = TreePattern.compile("add($x,$y)");
  * final Tree tree = TreeNode.parse("add(1,add(2,3))");
  * final TreeMatcher matcher = pattern.matcher(tree);
@@ -37,7 +37,7 @@
  * // Prints:
  * // add(1,add(2,3))
  * // add(2,3)
- * }
+ * } * * @see TreePattern#matcher(Tree) * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreePattern.java b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreePattern.java index 35ebeb30db..ad422d4583 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreePattern.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/rewriting/TreePattern.java @@ -62,16 +62,16 @@ * The string representation of a tree pattern is a parenthesis tree string, * with a special wildcard syntax for arbitrary subtrees. The subtree * variables are prefixed with a '$' and must be a valid Java identifier. - *
{@code
+ * {@snippet lang="java":
  * final TreePattern p1 = TreePattern.compile("add($a,add($b,sin(x)))");
  * final TreePattern p2 = TreePattern.compile("pow($x,$y)");
- * }
+ * } * * If you need to have values which start with a '$' character, you can escape * it with a '\'. - *
{@code
+ * {@snippet lang="java":
  * final TreePattern p1 = TreePattern.compile("concat($x,\\$foo)");
- * }
+ * } * * The second value, {@code $foo}, of the {@code concat} function is not treated * as pattern variable. @@ -79,18 +79,18 @@ * If you want to match against trees with a different value type than * {@code String}, you have to specify an additional type mapper function when * compiling the pattern string. - *
{@code
+ * {@snippet lang="java":
  * final TreePattern> p = TreePattern.compile(
  *     "add($a,add($b,sin(x)))",
  *     MathOp::toMathOp
  * );
- * }
+ * } * *

Expanding trees

* * The second functionality of the tree pattern is to expand a pattern to a whole * tree with a given pattern variable to subtree mapping. - *
{@code
+ * {@snippet lang="java":
  * final TreePattern pattern = TreePattern.compile("add($x,$y,1)");
  * final Map, Tree> vars = Map.of(
  *     Var.of("x"), TreeNode.parse("sin(x)"),
@@ -99,7 +99,7 @@
  *
  * final Tree tree = pattern.expand(vars);
  * assertEquals(tree.toParenthesesString(), "add(sin(x),sin(y),1)");
- * }
+ * } * * @see TreeRewriteRule * @see Tree#toParenthesesString() diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTree.java b/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTree.java index f00350fa18..379483cc2f 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTree.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTree.java @@ -69,10 +69,10 @@ public interface FlatTree> extends Tree { /** * Return the whole flattened tree values in breadth-first order. This is * equivalent to - *
{@code
+	 * {@snippet lang="java":
 	 * final ISeq seq = getRoot().breadthFirstStream()
 	 *     .collect(ISeq.toISeq());
-	 * }
+ * } * * @return the flattened tree values in breadth-first order */ diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTreeNode.java b/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTreeNode.java index 255df177bb..b750890c83 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTreeNode.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/util/FlatTreeNode.java @@ -48,9 +48,9 @@ * flattened and dense layout it is also an immutable implementation of * the {@link Tree} interface. It can only be created from an existing tree. * - *
{@code
+ * {@snippet lang="java":
  * final Tree immutable = FlatTreeNode.ofTree(TreeNode.parse(...));
- * }
+ * } * * @implNote * This class is immutable and thread-safe. @@ -186,11 +186,11 @@ public Stream> breadthFirstStream() { /** * Return a sequence of all mapped nodes of the whole underlying * tree. This is a convenient method for - *
{@code
+	 * {@snippet lang="java":
 	 * final ISeq seq = stream()
 	 *     .map(mapper)
 	 *     .collect(ISeq.toISeq())
-	 * }
+ * } * * @param mapper the mapper function * @param the mapped type @@ -353,12 +353,12 @@ public static FlatTreeNode parse(final String tree) { * 0(1(4,5),2(6),3(7(10,11),8,9)) * * and can be parsed to an integer tree with the following code: - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree tree = FlatTreeNode.parse(
 	 *     "0(1(4,5),2(6),3(7(10,11),8,9))",
 	 *     Integer::parseInt
 	 * );
-	 * }
+ * } * * @see Tree#toParenthesesString(Function) * @see Tree#toParenthesesString() diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/util/Tree.java b/jenetics.ext/src/main/java/io/jenetics/ext/util/Tree.java index 97891d0e39..fefc0137bf 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/util/Tree.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/util/Tree.java @@ -211,10 +211,10 @@ default int size() { * {@code null} and has no children and parent. A newly created tree node * with no value is empty. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree tree = TreeNode.of();
 	 * assert tree.isEmpty();
-	 * }
+ * } * * @since 7.0 * @@ -398,13 +398,13 @@ default ISeq pathElements() { /** * Return the {@link Path} of {@code this} tree, such that - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree tree = ...;
 	 * final Tree.Path path = tree.path();
 	 * assert tree == tree.getRoot()
 	 *     .childAtPath(path)
 	 *     .orElse(null);
-	 * }
+ * } * * @since 5.1 * @@ -921,12 +921,12 @@ default Iterator pathFromAncestorIterator(final Tree ancestor) { * Return the path of {@code this} child node from the root node. You will * get {@code this} node, if you call {@link #childAtPath(Path)} on the * root node of {@code this} node. - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree node = ...;
 	 * final Tree root = node.getRoot();
 	 * final int[] path = node.childPath();
 	 * assert node == root.childAtPath(path);
-	 * }
+ * } * * @since 4.4 * @@ -972,7 +972,7 @@ default boolean identical(final Tree other) { * Performs a reduction on the elements of {@code this} tree, using an * associative reduction function. This can be used for evaluating a given * expression tree in pre-order. - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree formula = TreeNode.parse("add(sub(6,div(230,10)),mul(5,6))");
 	 * final double result = formula.reduce(new Double[0], (op, args) ->
 	 *     switch (op) {
@@ -984,7 +984,7 @@ default boolean identical(final Tree other) {
 	 *     }
 	 * );
 	 * assert result == 13.0;
-	 * }
+ * } * * @since 7.1 * diff --git a/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java b/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java index e2f016dc20..46560e4c1f 100644 --- a/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java +++ b/jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java @@ -532,12 +532,12 @@ public static TreeNode ofTree(final Tree tree) { * The parse method doesn't strip the space between the parentheses and * the commas. If you want to remove this formatting space, * you should do the parsing with an addition mapper function. - *
{@code
+	 * {@snippet lang="java":
 	 * final TreeNode tree = TreeNode.parse(
 	 *     "mul(  div(cos( 1.0) , cos(π )), sin(mul(1.0, z) ) )",
 	 *     String::trim
 	 * );
-	 * }
+ * } * The code above will trim all tree nodes during the parsing process. * * @see Tree#toParenthesesString(Function) @@ -564,12 +564,12 @@ public static TreeNode parse(final String tree) { * 0(1(4,5),2(6),3(7(10,11),8,9)) * * and can be parsed to an integer tree with the following code: - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree tree = TreeNode.parse(
 	 *     "0(1(4,5),2(6),3(7(10,11),8,9))",
 	 *     Integer::parseInt
 	 * );
-	 * }
+ * } * * @see Tree#toParenthesesString(Function) * @see Tree#toParenthesesString() diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/BreathFirstIterator.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/BreathFirstIterator.java index f54721ebf1..c7802d85d6 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/BreathFirstIterator.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/BreathFirstIterator.java @@ -39,7 +39,7 @@ * It also tracks already visited nodes to prevent infinite loops in the traversal. * The following code example shows how to recursively travers the properties of * a simple domain model: - *
{@code
+ * {@snippet lang="java":
  * record Author(String forename, String surname) { }
  * record Book(String title, int pages, List authors) { }
  *
@@ -57,7 +57,7 @@
  * );
  *
  * it.forEachRemaining(System.out::println);
- * }
+ * } * * @param the source object type * @param the type of the extracted objects diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Filters.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Filters.java index 214ce1e93b..4f2b24aa8f 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Filters.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Filters.java @@ -28,7 +28,7 @@ /** * Helper methods for creating filter predicates. * - *
{@code
+ * {@snippet lang="java":
  * final Predicate filter = Stream.of(includes)
  *     .map(include -> Filters
  *         .filtering(
@@ -36,7 +36,7 @@
  *             Filters.ofGlob(include)
  *         )
  *     )
- * }
+ * } * * @author Franz Wilhelmstötter * @version 7.2 diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Path.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Path.java index b4e9e22cb5..ae1437d8e1 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Path.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Path.java @@ -349,9 +349,9 @@ public static Path of(final Element... elements) { * valid path consists of a names, which must be a valid Java identifier, * and indexes, separated by a dot, '.'. A valid path with three elements * will look like this: - *
{@code
+	 * {@snippet lang="java":
 	 * final var path = Path.of("name1.name2[9].value");
-	 * }
+ * } * * @param value the path value * @return a new property path diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PostOrderIterator.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PostOrderIterator.java index c277051637..745a256217 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PostOrderIterator.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PostOrderIterator.java @@ -36,7 +36,7 @@ * also tracks already visited nodes to prevent infinite loops in the traversal. * The following code example shows how to recursively travers the properties of * a simple domain model: - *
{@code
+ * {@snippet lang="java":
  * record Author(String forename, String surname) { }
  * record Book(String title, int pages, List authors) { }
  *
@@ -54,7 +54,7 @@
  * );
  *
  * it.forEachRemaining(System.out::println);
- * }
+ * } * * @param the source object type * @param the type of the extracted objects diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PreOrderIterator.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PreOrderIterator.java index 84e67b4357..2793747a81 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PreOrderIterator.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/PreOrderIterator.java @@ -40,7 +40,7 @@ * * The following code example shows how to recursively travers the properties of * a simple domain model: - *
{@code
+ * {@snippet lang="java":
  * record Author(String forename, String surname) { }
  * record Book(String title, int pages, List authors) { }
  *
@@ -58,7 +58,7 @@
  * );
  *
  * it.forEachRemaining(System.out::println);
- * }
+ * } * * @param the source object type * @param the type of the extracted objects diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Reflect.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Reflect.java index 64aabd6f8e..e7eaa4934c 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Reflect.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/Reflect.java @@ -60,12 +60,12 @@ private Reflect() { /** * Base interface used for matching {@link Type} objects. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Type type = ...;
 	 * if (ArrayType.of(type) instanceof ArrayType at) {
 	 *     System.out.println(at);
 	 * }
-	 * }
+ * } */ public sealed interface Trait { } @@ -194,12 +194,12 @@ public void set(Object object, int index, Object value) { /** * Return a {@code OptionalType} instance if the given {@code type} is a * {@code Optional} class. - *
{@code
+		 * {@snippet lang="java":
 		 * final Type type = ...;
 		 * if (OptionalType.of(type) instanceof OptionalType ot) {
 		 *     System.out.println(ot);
 		 * }
-		 * }
+ * } * * @param type the type object * @return an {@code OptionalType} if the given {@code type} is an @@ -262,12 +262,12 @@ public void set(Object object, int index, Object value) { /** * Return an {@code ArrayType} instance if the given {@code type} is an * array class. - *
{@code
+		 * {@snippet lang="java":
 		 * final Type type = ...;
 		 * if (ArrayType.of(type) instanceof ArrayType at) {
 		 *     System.out.println(at);
 		 * }
-		 * }
+ * } * * @param type the type object * @return an {@code ArrayType} if the given {@code type} is an array @@ -328,12 +328,12 @@ public void set(Object object, int index, Object value) { /** * Return a {@code ListType} instance if the given {@code type} is a * {@code List} class. - *
{@code
+		 * {@snippet lang="java":
 		 * final Type type = ...;
 		 * if (ListType.of(type) instanceof ListType lt) {
 		 *     System.out.println(lt);
 		 * }
-		 * }
+ * } * * @param type the type object * @return an {@code ListType} if the given {@code type} is a list type, @@ -451,12 +451,12 @@ public Stream components() { /** * Return a {@code RecordType} instance if the given {@code type} is a * {@code Record} class. - *
{@code
+		 * {@snippet lang="java":
 		 * final Type type = ...;
 		 * if (RecordType.of(type) instanceof RecordType rt) {
 		 *     System.out.println(rt);
 		 * }
-		 * }
+ * } * * @param type the type object * @return an {@code RecordType} if the given {@code type} is a record @@ -506,12 +506,12 @@ public Stream components() { /** * Return a {@code BeanType} instance if the given {@code type} is a * bean class. - *
{@code
+		 * {@snippet lang="java":
 		 * final Type type = ...;
 		 * if (BeanType.of(type) instanceof BeanType bt) {
 		 *     System.out.println(bt);
 		 * }
-		 * }
+ * } * * @param type the type object * @return an {@code ListType} if the given {@code type} is a bean type, diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/Descriptions.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/Descriptions.java index 3da9bf4caf..ef5c14bf64 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/Descriptions.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/Descriptions.java @@ -107,11 +107,11 @@ public static Stream unapply(final Type type) { * available property descriptions are returned. If used with the * {@link #unapply(PathValue)} method, all found descriptions are returned, * including the descriptions from the Java classes. - *
{@code
+	 * {@snippet lang="java":
 	 * Descriptions
 	 *     .walk(PathEntry.of(String.class), Descriptions::extract)
 	 *     .forEach(System.out::println);
-	 * }
+ * } * * The code snippet above will create the following output: * @@ -152,24 +152,24 @@ public static Stream walk( * available property descriptions are returned, and the property * descriptions from Java classes are not part of the result. * - *
{@code
+	 * {@snippet lang="java":
 	 * record Author(String forename, String surname) { }
 	 * record Book(String title, int pages, List authors) { }
 	 *
 	 * Descriptions.walk(PathEntry.of(Book.class))
 	 *     .forEach(System.out::println);
-	 * }
+ * } * * The code snippet above will create the following output: * - *
{@code
+	 * {@snippet lang="java":
 	 * Description[path=authors, value=Single[value=java.util.List, enclosure=Book]]
 	 * Description[path=authors[0], value=Indexed[value=Author, enclosure=java.util.List]]
 	 * Description[path=authors[0].forename, value=Single[value=java.lang.String, enclosure=Author]]
 	 * Description[path=authors[0].surname, value=Single[value=java.lang.String, enclosure=Author]]
 	 * Description[path=pages, value=Single[value=int, enclosure=Book]]
 	 * Description[path=title, value=Single[value=java.lang.String, enclosure=Book]]
-	 * }
+ * } * * @see #walk(PathValue, Dtor) * @see #walk(Type) diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/package-info.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/package-info.java index e6a25fb5c4..652bd18c81 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/package-info.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/description/package-info.java @@ -23,23 +23,23 @@ * The main entry point of this package is the * {@link io.jenetics.incubator.beans.description.Descriptions} object. * - *
{@code
+ * {@snippet lang="java":
  * record Author(String forename, String surname) { }
  * record Book(String title, int pages, List authors) { }
  *
  * Descriptions.walk(PathEntry.of(Book.class))
  *     .forEach(System.out::println);
- * }
+ * } * * The code snippet above will create the following output: * - *
{@code
+ * {@snippet lang="java":
  * Description[path=authors, value=Single[value=java.util.List, enclosure=Book]]
  * Description[path=authors[0], value=Indexed[value=Author, enclosure=java.util.List]]
  * Description[path=authors[0].forename, value=Single[value=java.lang.String, enclosure=Author]]
  * Description[path=authors[0].surname, value=Single[value=java.lang.String, enclosure=Author]]
  * Description[path=pages, value=Single[value=int, enclosure=Book]]
  * Description[path=title, value=Single[value=java.lang.String, enclosure=Book]]
- * }
+ * } */ package io.jenetics.incubator.beans.description; diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Properties.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Properties.java index 782d822316..75face0a10 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Properties.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Properties.java @@ -185,11 +185,11 @@ private static Property.Value toValue( * starting {@code root} object. If used with the {@link #unapply(PathValue)} * method, all found descriptions are returned, including the descriptions * from the Java classes. - *
{@code
+	 * {@snippet lang="java":
 	 * final var object = "Some Value";
 	 * Properties.walk(PathEntry.of(object), Properties::extract)
 	 *     .forEach(System.out::println);
-	 * }
+ * } * The code snippet above will create the following output: *
 	 * SimpleProperty[path=blank, value=Mutable[value=false, type=boolean, enclosureType=java.lang.String]]
@@ -226,7 +226,7 @@ public static Stream walk(
 	 * Return a {@code Stream} that is lazily populated with {@code Property}
 	 * by walking the object tree rooted at a given starting object.
 	 *
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * record Author(String forename, String surname) { }
 	 * record Book(String title, int pages, List authors) { }
 	 *
@@ -238,18 +238,18 @@ public static Stream walk(
 	 *
 	 * Properties.walk(PathEntry.of(object))
 	 *     .forEach(System.out::println);
-	 * }
+ * } * * The code snippet above will create the following output: * - *
{@code
+	 * {@snippet lang="java":
 	 * ListProperty[path=authors, value=Immutable[value=[Author[forename=Charles, surname=Dickens]], type=java.util.List, enclosureType=Book]]
 	 * IndexProperty[path=authors[0], value=Mutable[value=Author[forename=Charles, surname=Dickens], type=Author, enclosureType=java.util.ImmutableCollections$List12]]
 	 * SimpleProperty[path=authors[0].forename, value=Immutable[value=Charles, type=java.lang.String, enclosureType=Author]]
 	 * SimpleProperty[path=authors[0].surname, value=Immutable[value=Dickens, type=java.lang.String, enclosureType=Author]]
 	 * SimpleProperty[path=pages, value=Immutable[value=366, type=int, enclosureType=Book]]
 	 * SimpleProperty[path=title, value=Immutable[value=Oliver Twist, type=java.lang.String, enclosureType=Book]]
-	 * }
+ * } * * @see #walk(Object, String...) * diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Property.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Property.java index 56f19ae3a2..cb1aa5f94d 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Property.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/Property.java @@ -32,39 +32,39 @@ * bean property, with getter and setter, or as record component. The * following code shows how to create (a transitive) list of all properties from * a given root object. - *
{@code
+ * {@snippet lang="java":
  * final var root = ...;
  * final List properties = Properties
  *     // Get all properties from the 'root' object which are defined
  *     // in the 'io.jenetics' package.
  *     .stream(root, "io.jenetics")
  *     .toList();
- * }
+ * } * Only get string properties. - *
{@code
+ * {@snippet lang="java":
  * final List properties = Properties
  *     .stream(root, "io.jenetics")
  *     .filter(property -> property.type() == String.class)
  *     .toList();
- * }
+ * } * Only get the properties declared in the {@code MyBeanObject} class. - *
{@code
+ * {@snippet lang="java":
  * final List properties = Properties
  *     .stream(root, "io.jenetics")
  *     .filter(property -> property.object().getClass() == MyBeanObject.class)
  *     .toList();
- * }
+ * } * Only get properties with the name {@code index}. No matter where they defined * in the object hierarchy. - *
{@code
+ * {@snippet lang="java":
  * final List properties = Properties
  *     .stream(root, "io.jenetics")
  *     .filter(Property.pathMatcher("**index"))
  *     .toList();
- * }
+ * } * Updates all "index" properties with value {@code -1} to zero and returns all * properties, which couldn't be updated, because the property was immutable. - *
{@code
+ * {@snippet lang="java":
  * final List notUpdated = Properties
  *     .stream(root, "io.jenetics")
  *     .filter(Property.pathMatcher("**index"))
@@ -72,7 +72,7 @@
  *     .filter(property -> !property.write(0))
  *     .toList();
  * assert notUpdated.isEmpty();
- * }
+ * } * * @author Franz Wilhelmstötter * @version 7.2 diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/package-info.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/package-info.java index d4cd5a4341..8220eb05a3 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/package-info.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/beans/property/package-info.java @@ -23,7 +23,7 @@ * The main entry point of this package is the * {@link io.jenetics.incubator.beans.property.Properties} object. * - *
{@code
+ * {@snippet lang="java":
  * record Author(String forename, String surname) { }
  * record Book(String title, int pages, List authors) { }
  *
@@ -35,17 +35,17 @@
  *
  * Properties.walk(PathEntry.of(object))
  *     .forEach(System.out::println);
- * }
+ * } * * The code snippet above will create the following output: * - *
{@code
+ * {@snippet lang="java":
  * ListProperty[path=authors, value=Immutable[value=[Author[forename=Charles, surname=Dickens]], type=java.util.List, enclosureType=Book]]
  * IndexProperty[path=authors[0], value=Mutable[value=Author[forename=Charles, surname=Dickens], type=Author, enclosureType=java.util.ImmutableCollections$List12]]
  * SimpleProperty[path=authors[0].forename, value=Immutable[value=Charles, type=java.lang.String, enclosureType=Author]]
  * SimpleProperty[path=authors[0].surname, value=Immutable[value=Dickens, type=java.lang.String, enclosureType=Author]]
  * SimpleProperty[path=pages, value=Immutable[value=366, type=int, enclosureType=Book]]
  * SimpleProperty[path=title, value=Immutable[value=Oliver Twist, type=java.lang.String, enclosureType=Book]]
- * }
+ * } */ package io.jenetics.incubator.beans.property; diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/util/CsvSupport.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/util/CsvSupport.java index 06310fd720..fdfdd56d99 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/util/CsvSupport.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/util/CsvSupport.java @@ -45,7 +45,7 @@ * Helper methods for splitting CSV rows and merging CSV columns into a valid * CSV row. * - *
{@code
+ * {@snippet lang="java":
  * // Read CSV, including multiline CSV files, if properly quoted.
  * final List> rows;
  * try (Stream lines = CsvSupport.read(new FileReader("some_file.csv"))) {
@@ -57,7 +57,7 @@
  *     .map(CsvSupport::join)
  *     .collect(CsvSupport.toCsv());
  * Files.writeString(Path.of("some_other_file.csv"), csv);
- * }
+ * } * * @see RFC-4180 * @@ -94,11 +94,11 @@ private CsvSupport() { * in RFC-4180. This is * the reverse of the {@link #join(Iterable)} method. * - *
{@code
+	 * {@snippet lang="java":
 	 * final var line = "a,b,c,d,e,f";
 	 * final var cols = CsvSupport.split(line);
 	 * assert List.of("a", "b", "c", "d", "e", "f").equals(cols)
-	 * }
+ * } * * @see RFC-4180 * @see #split(CharSequence, String[], int...) @@ -129,11 +129,11 @@ public static List split(final CharSequence line, final int... indexes) * in RFC-4180. This is * the reverse of the {@link #join(Iterable)} method. * - *
{@code
+	 * {@snippet lang="java":
 	 * final var line = "a,b,c,d,e,f";
 	 * final var cols = new String[6]
 	 * CsvSupport.split(line, cols);
-	 * }
+ * } * * @param line the CSV {@code row} to split * @param columns the columns, where the split result is written to. The @@ -163,11 +163,11 @@ static boolean isTokenSeparator(final char c) { * Joins the given columns to a CSV line. This is the reverse operation of * the {@link #split(CharSequence, int...)} method. * - *
{@code
+	 * {@snippet lang="java":
 	 * final var cols = List.of("a", "b", "c", "d", "e", "f");
 	 * final var line = CsvSupport.join(cols);
 	 * assert "a,b,c,d,e,f".equals(line);
-	 * }
+ * } * * @see #split(CharSequence, int...) * @@ -217,13 +217,13 @@ private static boolean mustEscape(CharSequence value) { /** * Return a collector for joining a list of CSV rows into one CSV string. * - *
{@code
+	 * {@snippet lang="java":
 	 * final List> rows = ...;
 	 *
 	 * final String csv = rows.stream()
 	 *     .map(CsvSupport::join)
 	 *     .collect(CsvSupport.toCSV());
-	 * }
+ * } * * @return a collector for joining a list of CSV rows into one CSV string */ diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/util/Serializer.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/util/Serializer.java index 76de74c622..28384c886f 100644 --- a/jenetics.incubator/src/main/java/io/jenetics/incubator/util/Serializer.java +++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/util/Serializer.java @@ -52,7 +52,7 @@ * The methods of this class allow appending additional objects to an existing * file. * - *
{@code
+ * {@snippet lang="java":
  * // Write three string objects to the given path and read them again.
  * Serializer.write(path, List.of("1", "2", "3"));
  * List objects = Serializer.readAllObjects(path);
@@ -67,15 +67,15 @@
  * Serializer.write(path, List.of("6", "7", "8"), TRUNCATE_EXISTING);
  * objects = Serializer.readAllObjects(path);
  * assert objects.equals(List.of("6", "7", "8"));
- * }
+ * }
  *
  * It also allows reading object piecewise via a {@link Stream}.
  *
- * 
{@code
+ * {@snippet lang="java":
  * try (Stream stream = Serializer.objects(Path.of("serialized-objects.bin"))) {
  *     stream.forEach(System.out::println);
  * }
- * }
+ * }
  *
  * @author Franz Wilhelmstötter
  * @since 6.2
@@ -216,24 +216,24 @@ public void write(final byte[] b, final int off, final int len)
 	 * using Java serialization. For the first objects to be written
 	 * to the stream, the {@code append} flag must be set to {@code false}.
 	 *
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * final var output = new ByteArrayOutputStream();
 	 * Serializer.write(output, List.of("1", "2", "3"), false);
 	 *
 	 * var input = new ByteArrayInputStream(output.toByteArray());
 	 * final List objects = Serializer.readAllObjects(output);
 	 * assert objects.equals(List.of("1", "2", "3"));
-	 * }
+	 * }
 	 *
 	 * When writing additional objects to the same output stream, the
 	 * {@code append} must be set to {@code true}.
 	 *
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * Serializer.write(output, List.of("4", "5"), true);
 	 * input = new ByteArrayInputStream(output.toByteArray());
 	 * objects = Serializer.readAllObjects(input);
 	 * assert objects.equals(List.of("1", "2", "3", "4", "5"));
-	 * }
+ * } * * It is the responsibility of the caller to close the given {@code output} * stream when no longer needed. @@ -290,21 +290,21 @@ private static long write0( * {@code options} contains {@link StandardOpenOption#APPEND}, the objects * are appended to the existing file. * - *
{@code
+	 * {@snippet lang="java":
 	 * // Write three string objects to the given file. The file is created if
 	 * // it not exists or appended if the file already exists.
 	 * Serializer.write(path, List.of("1", "2", "3"));
-	 * }
+ * } * * Truncating an existing file: - *
{@code
+	 * {@snippet lang="java":
 	 * // Write three string objects to the given file. The file is truncated if
 	 * // it exists or created if the file doesn't exists.
 	 * Serializer.write(
 	 *     path, List.of("1", "2", "3"),
 	 *     StandardOpenOption.TRUNCATE_EXISTING
 	 * );
-	 * }
+ * } * * @see #write(Iterable, OutputStream, boolean) * @@ -380,12 +380,12 @@ private static boolean isEmpty(final Path file) throws IOException { * objects efficiently. Note that the caller is responsible for closing the * returned object stream, which also closes the given {@code input} stream. * - *
{@code
+	 * {@snippet lang="java":
 	 * final InputStream input = ...;
 	 * try (Stream stream = Serializer.objects(input)) {
 	 *     stream.forEach(System.out::println);
 	 * }
-	 * }
+	 * }
 	 *
 	 * @see #objects(Path)
 	 *
@@ -440,11 +440,11 @@ public synchronized Object get() {
 	 * read huge files efficiently. Note that the caller is responsible for
 	 * closing the returned object stream.
 	 *
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * try (Stream stream = Serializer.objects(path)) {
 	 *     stream.forEach(System.out::println);
 	 * }
-	 * }
+	 * }
 	 *
 	 * @see #objects(InputStream)
 	 *
diff --git a/jenetics.incubator/src/main/java/io/jenetics/incubator/util/TaskCompletion.java b/jenetics.incubator/src/main/java/io/jenetics/incubator/util/TaskCompletion.java
index c599d7dfd3..8b49096ddd 100644
--- a/jenetics.incubator/src/main/java/io/jenetics/incubator/util/TaskCompletion.java
+++ b/jenetics.incubator/src/main/java/io/jenetics/incubator/util/TaskCompletion.java
@@ -43,7 +43,7 @@
  * were submitted. The tasks are executed asynchronously, but not
  * concurrently.
  *
- * 
{@code
+ * {@snippet lang="java":
  * final var executor = new TaskCompletion(ForkJoinPool.commonPool());
  * final var results = new ArrayList();
  *
@@ -58,7 +58,7 @@
  * for (int i = 0; i < results.size(); ++i) {
  *     assert results.get(i) == i;
  * }
- * }
+ * } * * Since the tasks are executed in the submitted order and the next task is * executed if the previous one has been finished, it is not necessary to use diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java b/jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java index abf0f172f3..a7c6da8239 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/ProgramChromosome.java @@ -48,7 +48,7 @@ /** * Holds the nodes of the operation tree. * - *
{@code
+ * {@snippet lang="java":
  * final int depth = 6;
  * final ISeq> operations = ISeq.of(...);
  * final ISeq> terminals = ISeq.of(...);
@@ -59,7 +59,7 @@
  *     operations,
  *     terminals
  * );
- * }
+ * } * * @author Franz Wilhelmstötter * @version 4.1 @@ -357,7 +357,7 @@ public static ProgramChromosome of( * operation tree. If the tree is not valid, it will repair it. This * behaviour allows the safe usage of all existing alterers. * - *
{@code
+	 * {@snippet lang="java":
 	 * final ProgramChromosome ch = ProgramChromosome.of(
 	 *     genes,
 	 *     // If the program has more that 200 nodes, it is marked as "invalid".
@@ -365,7 +365,7 @@ public static  ProgramChromosome of(
 	 *     operations,
 	 *     terminals
 	 * );
-	 * }
+ * } * * @param genes the program genes * @param validator the chromosome validator to use diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java b/jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java index 29ef1c4cb9..4d576ff8d3 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/ProgramGene.java @@ -42,14 +42,14 @@ * error space. Since the {@code ProgramGene} also is a {@code Tree}, * it can be easily used as a result. * - *
{@code
+ * {@snippet lang="java":
  * final ProgramGene program = engine.stream()
  *     .limit(300)
  *     .collect(EvolutionResult.toBestGenotype())
  *     .getGene();
  *
  * final double result = program.eval(3.4);
- * }
+ * } * * @author
Franz Wilhelmstötter * @version 5.2 diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/BoolOp.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/BoolOp.java index 578d20795f..41d919e00d 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/BoolOp.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/BoolOp.java @@ -136,7 +136,7 @@ public String toString() { * an operation tree. If you use it that way, you should not forget to * re-index the tree variables. * - *
{@code
+	 * {@snippet lang="java":
 	 * final TreeNode> tree = TreeNode.parse(
 	 *     "and(or(x,y),not(y))",
 	 *     BoolOp::toBoolOp
@@ -145,7 +145,7 @@ public String toString() {
 	 * assert Program.eval(tree, false, false) == false;
 	 * Var.reindex(tree);
 	 * assert Program.eval(tree, false, false) == true;
-	 * }
+ * } * * @since 5.0 * diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java index 8048d4a91c..6d0e0a3cba 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/Const.java @@ -38,10 +38,10 @@ * is used when printing the program tree. The {@code Const} operation is a * terminal operation. * - *
{@code
+ * {@snippet lang="java":
  * final static Op PI = Const.of("π", Math.PI);
  * final static Op ONE = Const.of(1.0);
- * }
+ * } * * @author Franz Wilhelmstötter * @version 7.0 diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/ConstRewriter.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/ConstRewriter.java index c553cb97e5..67ea8c8448 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/ConstRewriter.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/ConstRewriter.java @@ -35,11 +35,11 @@ *

* The following example shows how to use the rewriter for a double operation * tree: - *

{@code
+ * {@snippet lang="java":
  * final TreeNode> tree = MathExpr.parseTree("1 + 2 + 3 + 4");
  * ConstRewriter.ofType(Double.class).rewrite(tree);
  * assert tree.getValue().equals(Const.of(10.0));
- * }
+ * } * * @param the operation type the rewriter is working on * diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/EphemeralConst.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/EphemeralConst.java index 095c75e754..fc24a57f23 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/EphemeralConst.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/EphemeralConst.java @@ -43,27 +43,27 @@ * particular terminal, and which will remain fixed for the given tree. The main * usage would be to introduce random terminal values. * - *
{@code
+ * {@snippet lang="java":
  * final Random random = ...;
  * final Op val = EphemeralConst.of(random::nextDouble);
- * }
+ * } * * Serialization * Although the {@code EphemeralConst} class implements the {@link Serializable} * interface, the serialization will fail if the const supplier is not * serializable as well. This can be achieved by casting the * supplier to a {@link Serializable}. - *
{@code
+ * {@snippet lang="java":
  * final Random random = new Random();
  * final EphemeralConst object = EphemeralConst.of(
  *     "R",
  *     (Supplier & Serializable)random::nextInt
  * );
- * }
+ * } * The serialization of the constant will fail, if the lambda has to * capture variables form a non-serializable context (class). In such a * case, it is advisable to create a dedicated supplier class. - *
{@code
+ * {@snippet lang="java":
  * final class RandomInt implements Supplier, Serializable {
  *     private final Random rnd = new Random();
  *     private final int min;
@@ -79,7 +79,7 @@
  *         return rnd.nextInt(max - min) + min;
  *     }
  * }
- * }
+ * } * * * @author Franz Wilhelmstötter diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java index b1c9869e9c..38381ef72b 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/MathExpr.java @@ -95,11 +95,11 @@ public final class MathExpr /** * This tree-rewriter rewrites constant expressions to its single value. * - *
{@code
+	 * {@snippet lang="java":
 	 * final TreeNode> tree = MathExpr.parseTree("1 + 2*(6 + 7)");
 	 * MathExpr.CONST_REWRITER.rewrite(tree);
 	 * assertEquals(tree.getValue(), Const.of(27.0));
-	 * }
+ * } * * @since 5.0 */ @@ -238,10 +238,10 @@ public Double apply(final Double[] args) { * Convenient method, which lets you apply the program function without * explicitly create a wrapper array. * - *
{@code
+	 * {@snippet lang="java":
 	 *  final double result = MathExpr.parse("2*z + 3*x - y").eval(3, 2, 1);
 	 *  assert result == 9.0;
-	 * }
+ * } * * @see #apply(Double[]) * @see #eval(String, double...) @@ -273,11 +273,11 @@ public boolean equals(final Object obj) { * Return the string representation of this {@code MathExpr} object. The * string returned by this method can be parsed again and will result in the * same expression object. - *
{@code
+	 * {@snippet lang="java":
 	 *  final String expr = "5.0 + 6.0*x + sin(x)^34.0 + (1.0 + sin(x*5.0)/4.0) + 6.5";
 	 *  final MathExpr tree = MathExpr.parse(expr);
 	 *  assert tree.toString().equals(expr);
-	 * }
+ * } * * @return the expression string */ @@ -398,11 +398,11 @@ static MathExpr read(final DataInput in) throws IOException { * Return the string representation of the given {@code tree} object. The * string returned by this method can be parsed again and will result in the * same expression object. - *
{@code
+	 * {@snippet lang="java":
 	 *  final String expr = "5.0 + 6.0*x + sin(x)^34.0 + (1.0 + sin(x*5.0)/4.0) + 6.5";
 	 *  final MathExpr tree = MathExpr.parse(expr);
 	 *  assert MathExpr.format(tree.tree()).equals(expr);
-	 * }
+ * } * * @since 4.3 * @@ -431,10 +431,10 @@ public static MathExpr parse(final String expression) { * Parses the given mathematical expression string and returns the * mathematical expression tree. The expression may contain all functions * defined in {@link MathOp}. - *
{@code
+	 * {@snippet lang="java":
 	 * final Tree, ?> tree = MathExpr
 	 *     .parseTree("5 + 6*x + sin(x)^34 + (1 + sin(x*5)/4)/6");
-	 * }
+ * } * The example above will lead to the following tree: *
 {@code
 	 *  add
@@ -481,10 +481,10 @@ public static MathExpr parse(final String expression) {
 	/**
 	 * Evaluates the given {@code expression} with the given arguments.
 	 *
-	 * 
{@code
+	 * {@snippet lang="java":
 	 *  final double result = MathExpr.eval("2*z + 3*x - y", 3, 2, 1);
 	 *  assert result == 9.0;
-	 * }
+ * } * * @see #apply(Double[]) * @see #eval(double...) diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/MathOp.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/MathOp.java index c61d0b90c8..9b2985b4be 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/MathOp.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/MathOp.java @@ -415,7 +415,7 @@ public String toString() { * an operation tree. If you use it that way, you should not forget to * re-index the tree variables. * - *
{@code
+	 * {@snippet lang="java":
 	 * final TreeNode> tree = TreeNode.parse(
 	 *     "add(mul(x,y),sub(y,x))",
 	 *     MathOp::toMathOp
@@ -424,7 +424,7 @@ public String toString() {
 	 * assert Program.eval(tree, 10.0, 5.0) == 100.0;
 	 * Var.reindex(tree);
 	 * assert Program.eval(tree, 10.0, 5.0) == 45.0;
-	 * }
+ * } * * @since 5.0 * diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/MathStringTokenizer.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/MathStringTokenizer.java index a7d684c3a0..8173256e6c 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/MathStringTokenizer.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/MathStringTokenizer.java @@ -42,7 +42,7 @@ /** * Tokenizer for simple arithmetic expressions. * - *
{@code
+ * {@snippet lang="java":
  * LPAREN: '(';
  * RPAREN: ')';
  * COMMA: ',';
@@ -54,7 +54,7 @@
  * NUMBER: ('0'..'9')+ ('.' ('0'..'9')+)? ((e|E) (+|-)? ('0'..'9'))?
  * ID: ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')+;
  * WS: [ \r\n\t] + -> skip;
- * }
+ * } * * @author Franz Wilhelmstötter * @since 7.1 diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/Op.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/Op.java index c1044639a6..51351e9c6e 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/Op.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/Op.java @@ -31,12 +31,12 @@ * with a given arity to a result object of the same type: * {@code T[] -> T}. * - *
{@code
+ * {@snippet lang="java":
  * final Op add = Op.of("add", 2, v -> v[0] + v[1]);
  * final Op add3 = Op.of("add3", 3, v -> v[0] + v[1] + v[2]);
  * final Op sub = Op.of("sub", 2, v -> v[0] - v[1]);
  * final Op sin = Op.of("sin", 1, v -> Math.sin(v[0]));
- * }
+ * } * * Implementations of the {@code Op} interface are usually immutable and doesn't * maintain internal state. But some instances are ephemeral with changing state. diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java index 01a75f6804..e848f7f0be 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/Program.java @@ -149,9 +149,9 @@ public String toString() { /** * Evaluates the given operation tree with the given variables. This method * is equivalent to - *
{@code
+	 * {@snippet lang="java":
 	 * final T result = tree.reduce(variables, Op::apply);
-	 * }
+ * } * but handles the variable sized {@code variables} array more conveniently. * * @see Tree#reduce(Object[], BiFunction) diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/Var.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/Var.java index cf12f23d0f..6c27b80081 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/Var.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/Var.java @@ -43,17 +43,17 @@ * of the n-dimensional input space to the 1-dimensional * result space. * - *
{@code
+ * {@snippet lang="java":
  * final ISeq> operations = ISeq.of(...);
  * final ISeq> terminals = ISeq.of(
  *     Var.of("x", 0), Var.of("y", 1)
  * );
- * }
+ * } * * The example above shows how to define the terminal operations for a GP, which * tries to optimize a 2-dimensional function. * - *
{@code
+ * {@snippet lang="java":
  * static double error(final ProgramChromosome program) {
  *     final double x = ...;
  *     final double y = ...;
@@ -61,7 +61,7 @@
  *     ...
  *     return ...;
  * }
- * }
+ * } * * @implNote * The {@code Var} object is comparable, according its name. @@ -247,7 +247,7 @@ public static Var parse(final String name) { * the variables. The indices of the variables are assigned according it's * natural order. * - *
{@code
+	 * {@snippet lang="java":
 	 * final TreeNode> tree = TreeNode.parse(
 	 *     "add(mul(x,y),sub(y,x))",
 	 *     MathOp::toMathOp
@@ -256,7 +256,7 @@ public static  Var parse(final String name) {
 	 * assert Program.eval(tree, 10.0, 5.0) == 100.0; // wrong result
 	 * Var.reindex(tree);
 	 * assert Program.eval(tree, 10.0, 5.0) == 45.0; // correct result
-	 * }
+ * } * The example above shows a use-case of this method. If you parse a tree * string and convert it to an operation tree, you have to re-index the * variables first. If not, you will get the wrong result when evaluating @@ -291,7 +291,7 @@ public static void reindex(final TreeNode> tree) { * of the variables ({@link Var}), are all set to zero, since it needs the * whole tree for setting the indices correctly. * - *
{@code
+	 * {@snippet lang="java":
 	 * final TreeNode> tree = TreeNode.parse(
 	 *     "add(mul(x,y),sub(y,x))",
 	 *     MathOp::toMathOp
@@ -303,7 +303,7 @@ public static  void reindex(final TreeNode> tree) {
 	 * indexes.put(Var.of("y"), 1);
 	 * Var.reindex(tree, indexes);
 	 * assert Program.eval(tree, 10.0, 5.0) == 45.0; // correct result
-	 * }
+ * } * The example above shows a use-case of this method. If you parse a tree * string and convert it to an operation tree, you have to re-index the * variables first. If not, you will get the wrong result when evaluating diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/op/package-info.java b/jenetics.prog/src/main/java/io/jenetics/prog/op/package-info.java index 9c6857d20c..8609f792c3 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/op/package-info.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/op/package-info.java @@ -25,17 +25,17 @@ * instance of the {@code ProgramGene} or {@code ProgramChromosome} class. The * extension point for own programs is the {@code Op} interface. * - *
{@code
+ * {@snippet lang="java":
  * public interface Op {
  *     public String name();
  *     public int arity();
  *     public T apply(T[] args);
  * }
- * }
+ * } * - *
{@code
+ * {@snippet lang="java":
  * final Op myop = Op.of("myop", 3, v -> v[0]*v[1] + v[2]);
- * }
+ * } * * In the example above, a new operation with the "myop" and arity 3 is defined. * Whenever the operation is evaluated, the function f(x, y, z) = x*y + z @@ -64,11 +64,11 @@ * The {@code Var} operation defines a variable of a program, which are set * from the program arguments. * - *
{@code
+ * {@snippet lang="java":
  * final ISeq> terminals = ISeq.of(
  *     Var.of("x", 0), Var.of("y", 1), Var.of("z", 2)
  * );
- * }
+ * } * * The terminal operation list in the example code above will lead to a program * which takes three input parameters, x, y and z, @@ -79,10 +79,10 @@ * The {@code Const} operation will always return the same, constant, value * when evaluated. * - *
{@code
+ * {@snippet lang="java":
  * final Op one = Const.of(1.0);
  * final Op pi = Const.of("π", Math.PI);
- * }
+ * } * * We can create a constant operation in to flavors, with a value only and with * a dedicated name. If a constant has a name, the symbolic name is @@ -95,10 +95,10 @@ * {@link java.util.function.Supplier} function the ephemeral constant is created * with. * - *
{@code
+ * {@snippet lang="java":
  * final Op rand1 = EphemeralConst.of(Math::random);
  * final Op rand2 = EphemeralConst.of("R", Math::random);
- * }
+ * } * * * @author Franz Wilhelmstötter diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/package-info.java b/jenetics.prog/src/main/java/io/jenetics/prog/package-info.java index 0703b42372..4f5ed898b8 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/package-info.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/package-info.java @@ -54,7 +54,7 @@ * polynomial example we will chose the following operations * and terminals. * - *
{@code
+ * {@snippet lang="java":
  * static final ISeq> OPERATIONS = ISeq.of(
  *     MathOp.ADD,
  *     MathOp.SUB,
@@ -65,7 +65,7 @@
  *     Var.of("x", 0),
  *     EphemeralConst.of(() -> (double)RandomRegistry.getRandom().nextInt(10))
  * );
- * }
+ * } * * The chosen non-terminal operation set is sufficient to create any polynomial. * For the terminal operations, we added a variable "x", with index zero, and @@ -76,7 +76,7 @@ * In the next step define the fitness function for the GP, which will be an * error function we will minimize. * - *
{@code
+ * {@snippet lang="java":
  * // The lookup table where the data points are stored.
  * static final double[][] SAMPLES = new double[][] {
  *     {-1.0, -8.0000},
@@ -93,7 +93,7 @@
  *     })
  *     .sum();
  * }
- * }
+ * } * * The error function calculates the sum of the (absolute) difference between * the sample value and the value calculated the by the evolved program @@ -110,7 +110,7 @@ * After we have defined the error function, we need to define the proper * {@code Codec}. * - *
{@code
+ * {@snippet lang="java":
  * static final Codec, ProgramGene> CODEC =
  *     Codec.of(
  *         Genotype.of(ProgramChromosome.of(
@@ -123,7 +123,7 @@
  *         )),
  *         Genotype::gene
  *     );
- * }
+ * } * * * There are two particularities in the definition of the @@ -140,7 +140,7 @@ * * Now we are ready to put everything together: * - *
{@code
+ * {@snippet lang="java":
  * public static void main(final String[] args) {
  *     final Engine, Double> engine = Engine
  *         .builder(Polynomial::error, CODEC)
@@ -157,7 +157,7 @@
  *
  *     System.out.println(Tree.toString(program));
  * }
- * }
+ * } * * The GP is capable of finding the polynomial which created the sample data. * After a few tries, we got the following (correct) output program: diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/regression/Complexity.java b/jenetics.prog/src/main/java/io/jenetics/prog/regression/Complexity.java index 14c6c58564..d2d26c110c 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/regression/Complexity.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/regression/Complexity.java @@ -32,9 +32,9 @@ * values are preferred. It is part of the overall {@link Error} * function. * - *
{@code
+ * {@snippet lang="java":
  * final Error error = Error.of(LossFunction::mse, Complexity.ofNodeCount(50));
- * }
+ * } * * @see LossFunction * @see Error @@ -87,10 +87,10 @@ static Complexity ofNodeCount(final int maxNodeCount) { * If the node count is bigger or equal {@code maxNodes}, one is returned. *

* The complexity is calculated in the following way: - *

{@code
+	 * {@snippet lang="java":
 	 * final double cc = min(program.size() - 1, maxNodes);
 	 * return 1.0 - sqrt(1.0 - (cc*cc)/(maxNodes*maxNodes));
-	 * }
+ * } * * @see #ofNodeCount(int) * diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/regression/Error.java b/jenetics.prog/src/main/java/io/jenetics/prog/regression/Error.java index 20267245d9..b98a4abfaf 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/regression/Error.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/regression/Error.java @@ -32,9 +32,9 @@ * The error is calculated from the {@link LossFunction} and, if desired, the * program {@link Complexity}. * - *
{@code
+ * {@snippet lang="java":
  * final Error error = Error.of(LossFunction::mse, Complexity.ofNodeCount(50));
- * }
+ * } * * @see LossFunction * @see Complexity diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/regression/LossFunction.java b/jenetics.prog/src/main/java/io/jenetics/prog/regression/LossFunction.java index 581d2137bf..db4fd54a77 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/regression/LossFunction.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/regression/LossFunction.java @@ -32,9 +32,9 @@ * output a higher value. If they're pretty good, it’ll output a lower number. * It is the essential part of the overall {@link Error} function. * - *
{@code
+ * {@snippet lang="java":
  * final Error error = Error.of(LossFunction::mse);
- * }
+ * } * * @see Loss function * diff --git a/jenetics.prog/src/main/java/io/jenetics/prog/regression/Regression.java b/jenetics.prog/src/main/java/io/jenetics/prog/regression/Regression.java index 545b1aaefd..01fbcf30a4 100644 --- a/jenetics.prog/src/main/java/io/jenetics/prog/regression/Regression.java +++ b/jenetics.prog/src/main/java/io/jenetics/prog/regression/Regression.java @@ -45,7 +45,7 @@ * This class implements a symbolic regression problem. The example * below shows a typical usage of the {@code Regression} class. * - *
{@code
+ * {@snippet lang="java":
  * public class SymbolicRegression {
  *     private static final ISeq> OPERATIONS =
  *         ISeq.of(MathOp.ADD, MathOp.SUB, MathOp.MUL);
@@ -88,7 +88,7 @@
  *         System.out.println("Error:       " + REGRESSION.error(tree));
  *     }
  * }
- * }
+ * } * * @see SampleBuffer * @see Sampling diff --git a/jenetics.tool/src/main/java/io/jenetics/tool/trial/SampleSummaryStatistics.java b/jenetics.tool/src/main/java/io/jenetics/tool/trial/SampleSummaryStatistics.java index e804d27e7e..2254ae7993 100644 --- a/jenetics.tool/src/main/java/io/jenetics/tool/trial/SampleSummaryStatistics.java +++ b/jenetics.tool/src/main/java/io/jenetics/tool/trial/SampleSummaryStatistics.java @@ -34,14 +34,14 @@ * variance, skewness and kurtosis. The design of this class is similar to the * {@link java.util.DoubleSummaryStatistics} class. * - *
{@code
+ * {@snippet lang="java":
  * final Stream stream = ...
  * final SampleSummaryStatistics statistics = stream.collect(
  *         () -> new SampleSummaryStatistics(parameterCount),
  *         SampleSummaryStatistics::accept,
  *         SampleSummaryStatistics::combine
  *     );
- * }
+ * } * *

* Implementation note: @@ -141,11 +141,11 @@ public ISeq getQuantiles() { * function to each input element, and returns moments-statistics for the * resulting values. * - *

{@code
+	 * {@snippet lang="java":
 	 * final Stream stream = ...
 	 * final SampleSummaryStatistics statistics = stream
 	 *     .collect(toDoubleMomentStatistics(parameterCount));
-	 * }
+ * } * * @param parameterCount the number of parameter of the accumulated * {@code Sample} objects diff --git a/jenetics.xml/src/main/java/io/jenetics/xml/BoundedGeneCreator.java b/jenetics.xml/src/main/java/io/jenetics/xml/BoundedGeneCreator.java index a69ffe3c96..3269cd056e 100644 --- a/jenetics.xml/src/main/java/io/jenetics/xml/BoundedGeneCreator.java +++ b/jenetics.xml/src/main/java/io/jenetics/xml/BoundedGeneCreator.java @@ -35,9 +35,9 @@ public interface BoundedGeneCreator { /** * Create a new bounded gene from the given parameters. * - *
{@code
+	 * {@snippet lang="java":
 	 * final BoundedGeneCreator creator = LongGene::of;
-	 * }
+ * } * * @param value the gene value * @param min the minimum value diff --git a/jenetics.xml/src/main/java/io/jenetics/xml/Readers.java b/jenetics.xml/src/main/java/io/jenetics/xml/Readers.java index 542f68203f..a0645d1b3e 100644 --- a/jenetics.xml/src/main/java/io/jenetics/xml/Readers.java +++ b/jenetics.xml/src/main/java/io/jenetics/xml/Readers.java @@ -52,16 +52,16 @@ * This class contains static fields and methods, for creating chromosome- and * genotype readers for different gene types. * - *
{@code
- * final Reader bgr =
- *     Readers.Genotype.reader(Readers.BitChromosome.reader()));
+ * {@snippet lang="java":
+ * final Reader> bgr =
+ *     Readers.Genotype.reader(Readers.BitChromosome.reader());
  *
  * final Reader> igr =
- *     Writers.Genotype.reader(Readers.IntegerChromosome.reader()));
+ *     Writers.Genotype.reader(Readers.IntegerChromosome.reader());
  *
  * final Reader> dgr =
- *     Readers.Genotype.reader(Readers.DoubleChromosome.reader()));
- * }
+ * Readers.Genotype.reader(Readers.DoubleChromosome.reader()); + * } * * @author Franz Wilhelmstötter * @version 3.9 @@ -78,7 +78,6 @@ private Readers() {} *
 {@code
 	 * 11100011101011001010
 	 * } 
- * } */ public static final class BitChromosome { private BitChromosome() {} @@ -393,7 +392,7 @@ public static io.jenetics.LongChromosome read(final InputStream in) * 0.43947528327497376 * * - * }
+ * } */ public static final class DoubleChromosome { private DoubleChromosome() {} diff --git a/jenetics.xml/src/main/java/io/jenetics/xml/Writers.java b/jenetics.xml/src/main/java/io/jenetics/xml/Writers.java index 1c0423d23b..097d630d45 100644 --- a/jenetics.xml/src/main/java/io/jenetics/xml/Writers.java +++ b/jenetics.xml/src/main/java/io/jenetics/xml/Writers.java @@ -47,7 +47,7 @@ * This class contains static fields and methods, for creating chromosome- and * genotype writers for different gene types. * - *
{@code
+ * {@snippet lang="java":
  * final Writer bgw =
  *     Writers.Genotype.writer(Writers.BitChromosome.writer()));
  *
@@ -56,16 +56,16 @@
  *
  * final Writer> dgw =
  *     Writers.Genotype.writer(Writers.DoubleChromosome.writer()));
- * }
+ * } * * This class also contains some helper methods, which makes it easier to write * Jenetics domain objects to a given output stream. - *
{@code
+ * {@snippet lang="java":
  * final List> genotypes = ...;
  * try (OutputStream out = Files.newOutputStream(Paths.get("path"))) {
  *     Writers.write(out, genotypes, Writers.BitChromosome.writer());
  * }
- * }
+ * } * * @author Franz Wilhelmstötter * @version 3.9 @@ -79,12 +79,12 @@ private Writers() {} * {@link io.jenetics.BitChromosome} objects. *

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final BitChromosome value = BitChromosome.of(20, 0.5);
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     Writers.BitChromosome.writer().write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -148,12 +148,12 @@ public static void write(
 	 * {@link io.jenetics.CharacterChromosome} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final CharacterChromosome value = CharacterChromosome.of("ASDF", CharSeq.of("A-Z"));
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     Writers.CharacterChromosome.writer().write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -303,13 +303,13 @@ Writer writer(
 	 * {@link io.jenetics.IntegerChromosome} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final IntegerChromosome value = IntegerChromosome
 	 *     .of(Integer.MIN_VALUE, Integer.MAX_VALUE, 3);
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     Writers.IntegerChromosome.writer().write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -424,13 +424,13 @@ public static void write(
 	 * {@link io.jenetics.LongChromosome} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final LongChromosome value = LongChromosome
 	 *     .of(Long.MIN_VALUE, Long.MAX_VALUE, 3);
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     Writers.LongChromosome.writer().write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -543,12 +543,12 @@ public static void write(
 	 * {@link io.jenetics.DoubleChromosome} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final DoubleChromosome value = DoubleChromosome.of(0.0, 1.0, 3);
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     Writers.DoubleChromosome.writer().write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -667,7 +667,7 @@ public static void write(
 	 * {@link io.jenetics.PermutationChromosome} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final PermutationChromosome value =
 	 *     PermutationChromosome.ofInteger(5)
 	 *
@@ -677,7 +677,7 @@ public static void write(
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     Writers.PermutationChromosome.writer().write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -739,10 +739,10 @@ private static String toAlleleTypeName(
 		 * Create a writer for permutation-chromosomes. The valid alleles are
 		 * serialized by calling the {@link Object#toString()} method. Calling
 		 * this method is equivalent with:
-		 * 
{@code
+		 * {@snippet lang="java":
 		 * final Writer writer =
 		 *     PermutationChromosome.write(text().map(Objects::toString));
-		 * }
+ * } * * Example output: *
 {@code
@@ -887,7 +887,7 @@ public static  void write(
 	 * {@link io.jenetics.Genotype} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final Genotype gt = Genotype.of(
 	 *     DoubleChromosome.of(0.0, 1.0, 3),
 	 *     DoubleChromosome.of(0.0, 1.0, 2)
@@ -898,7 +898,7 @@ public static  void write(
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     writer.write(value, xml);
 	 * }
-	 * }
+ * } * * XML output *
 {@code
@@ -1044,7 +1044,7 @@ void write(
 	 * {@link io.jenetics.Genotype} objects.
 	 * 

* Writer code - *

{@code
+	 * {@snippet lang="java":
 	 * final Genotype gt = Genotype.of(
 	 *     DoubleChromosome.of(0.0, 1.0, 3),
 	 *     DoubleChromosome.of(0.0, 1.0, 2)
@@ -1056,7 +1056,7 @@ void write(
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(System.out, "    ")) {
 	 *     writer.write(asList(value), xml);
 	 * }
-	 * }
+ * } * *
 {@code
 	 * 
@@ -1092,10 +1092,10 @@ private Genotypes() {}
 		 * Create a writer for genotypes of arbitrary chromosomes. How to write the
 		 * genotype chromosomes is defined by the given {@link Writer}. The
 		 * following writer allows writing double-gene chromosomes:
-		 * 
{@code
+		 * {@snippet lang="java":
 		 * final Writer>> writer =
 		 *     Writers.Genotypes.writer(Writers.DoubleChromosome.writer());
-		 * }
+ * } * * @param writer the chromosome writer * @param
the allele type diff --git a/jenetics.xml/src/main/java/io/jenetics/xml/stream/Reader.java b/jenetics.xml/src/main/java/io/jenetics/xml/stream/Reader.java index 605c4a66fc..2b7e9910ca 100644 --- a/jenetics.xml/src/main/java/io/jenetics/xml/stream/Reader.java +++ b/jenetics.xml/src/main/java/io/jenetics/xml/stream/Reader.java @@ -43,7 +43,6 @@ /** * XML reader class, used for reading objects in XML format. - * * XML *
 {@code
  * 
@@ -55,10 +54,10 @@
  *         -88668137
  *     
  * 
- * }
+ * }
* * Reader definition - *
{@code
+ * {@snippet lang="java":
  * final Reader reader =
  *     elem(
  *         (Object[] v) -> {
@@ -70,7 +69,7 @@
  *
  *             return IntegerChromosome.of(
  *                 alleles.stream()
- *                     .map(value -> IntegerGene.of(value, min, max)
+ *                     .map(value -> IntegerGene.of(value, min, max))
  *                     .toArray(IntegerGene[]::new)
  *             );
  *         },
@@ -82,7 +81,7 @@
  *             elems(elem("allele", text().map(Integer::parseInt)))
  *         )
  *     );
- * }
+ * } * * @author
Franz Wilhelmstötter * @version 3.9 @@ -135,13 +134,13 @@ enum Type { /** * Read the given type from the underlying XML stream {@code reader}. * - *
{@code
+	 * {@snippet lang="java":
 	 * try (AutoCloseableXMLStreamReader xml = XML.reader(in)) {
-	 *     // Move XML stream to first element.
+	 *     // Move XML stream to first the element.
 	 *     xml.next();
 	 *     return reader.read(xml);
 	 * }
-	 * }
+ * } * * @param xml the underlying XML stream {@code reader} * @return the data read from the XML stream, maybe {@code null} @@ -208,10 +207,10 @@ public String toString() { * Return a {@code Reader} for reading an attribute of an element. *

* XML - *

 {@code }
+ *
 {@code }
 	 *
 	 * Reader definition
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * final Reader reader =
 	 *     elem(
 	 *         v -> (Integer)v[0],
@@ -232,10 +231,10 @@ public static Reader attr(final String name) {
 	 * Return a {@code Reader} for reading the text of an element.
 	 * 

* XML - *

 {@code 1234}
+ *
 {@code 1234}
 	 *
 	 * Reader definition
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * final Reader reader =
 	 *     elem(
 	 *         v -> (Integer)v[0],
@@ -256,10 +255,10 @@ public static Reader text() {
 	 *
 	 * 

* XML - *

 {@code 1234}
+ *
 {@code 1234}
 	 *
 	 * Reader definition
-	 * 
{@code
+	 * {@snippet lang="java":
 	 * final Reader reader =
 	 *     elem(
 	 *         v -> {
@@ -301,10 +300,12 @@ public static  Reader elem(
 	 * the given parent element {@code name}.
 	 * 

* XML - *

 {@code 1234} 
+ *
 {@code
+	 * 1234}
+	 * 
* * Reader definition - *
{@code
+	 * {@snippet lang="java":
 	 * final Reader reader =
 	 *     elem("min",
 	 *         elem(
@@ -318,7 +319,7 @@ public static  Reader elem(
 	 *             text().map(Integer::parseInt)
 	 *         )
 	 *     );
-	 * }
+ * } * * @param name the parent element name * @param reader the child elements reader @@ -358,14 +359,14 @@ public static Reader elem( * }
* * Reader definition - *
{@code
+	 * {@snippet lang="java":
 	 * Reader> reader =
 	 *     elem(
 	 *         v -> (List)v[0],
 	 *         "properties",
 	 *         elems(elem("property", text().map(Integer::parseInt)))
 	 *     );
-	 * } 
+ * } * * @param reader the child element reader * @param the element type diff --git a/jenetics.xml/src/main/java/io/jenetics/xml/stream/Writer.java b/jenetics.xml/src/main/java/io/jenetics/xml/stream/Writer.java index 9810f779b7..a85cfde626 100644 --- a/jenetics.xml/src/main/java/io/jenetics/xml/stream/Writer.java +++ b/jenetics.xml/src/main/java/io/jenetics/xml/stream/Writer.java @@ -43,7 +43,7 @@ * * The XML has been written by the following {@code Writer} definition. * - *
{@code
+ * {@snippet lang="java":
  * final Writer writer =
  *     elem("int-chromosome",
  *         attr("length").map(ch -> ch.length()),
@@ -54,16 +54,16 @@
  *                 .map(ch -> ISeq.of(ch).map(g -> g.getAllele()))
  *         )
  *     );
- * }
+ * } * * How to write the XML writing is shown by the next code snippet. * - *
{@code
+ * {@snippet lang="java":
  * final IntegerChromosome ch = IntegerChromosome.of(MIN_VALUE, MAX_VALUE, 3);
  * try (AutoCloseableXMLStreamWriter xml = XML.writer(out, indent)) {
  *     write(ch, xml);
  * }
- * }
+ * } * * @author Franz Wilhelmstötter * @version 3.9 @@ -120,9 +120,9 @@ default Writer map(final Function mapper) { * Writes the attribute with the given {@code name} to the current * outer element. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Writer writer1 = elem("element", attr("attribute"));
-	 * }
+ * } * * @see #attr(String, Object) * @@ -145,9 +145,9 @@ static Writer attr(final String name) { * Writes the attribute with the given {@code name} and a constant * {@code value} to the current outer element. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Writer = elem("element", attr("version", "1.0"));
-	 * }
+ * } * * @param name the attribute name * @param value the attribute value diff --git a/jenetics.xml/src/main/java/io/jenetics/xml/stream/XML.java b/jenetics.xml/src/main/java/io/jenetics/xml/stream/XML.java index 1881021bc3..630d967762 100644 --- a/jenetics.xml/src/main/java/io/jenetics/xml/stream/XML.java +++ b/jenetics.xml/src/main/java/io/jenetics/xml/stream/XML.java @@ -34,28 +34,28 @@ * {@link javax.xml.stream.XMLStreamWriter} objects. *

* Creating a new XML stream reader: - *

{@code
+ * {@snippet lang="java":
  * try (AutoCloseableXMLStreamReader xml = XML.reader(in)) {
  *     // Move XML stream to first element.
  *     xml.next();
  *     return reader.read(xml);
  * }
- * }
+ * } * * Create a new XML stream reader: - *
{@code
+ * {@snippet lang="java":
  * try (AutoCloseableXMLStreamWriter xml = XML.writer(out)) {
  *     writer.write(value, xml);
  * }
- * }
+ * } * * Create a new XML stream reader with pretty-print-indentation: - *
{@code
+ * {@snippet lang="java":
  * final String indent = "    ";
  * try (AutoCloseableXMLStreamWriter xml = XML.writer(out, indent)) {
  *     writer.write(value, xml);
  * }
- * }
+ * } * * @author Franz Wilhelmstötter * @version 3.9 @@ -70,13 +70,13 @@ private XML() {} * The caller is responsible for closing the returned {@code XMLStreamReader}. * * - *
{@code
+	 * {@snippet lang="java":
 	 * try (AutoCloseableXMLStreamReader xml = XML.reader(in)) {
 	 *     // Move XML stream to first element.
 	 *     xml.next();
 	 *     return reader.read(xml);
 	 * }
-	 * }
+ * } * * @param input the input stream * @return a new {@code Closeable} XML stream reader @@ -102,11 +102,11 @@ public static AutoCloseableXMLStreamReader reader(final InputStream input) * The caller is responsible for closing the returned {@code XMLStreamWriter}. * * - *
{@code
+	 * {@snippet lang="java":
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(out, "    ")) {
 	 *     writer.write(value, xml);
 	 * }
-	 * }
+ * } * * @param output the underlying output stream * @param indent the element indent used for the XML output @@ -138,11 +138,11 @@ public static AutoCloseableXMLStreamWriter writer( * The caller is responsible for closing the returned {@code XMLStreamWriter}. * * - *
{@code
+	 * {@snippet lang="java":
 	 * try (AutoCloseableXMLStreamWriter xml = XML.writer(out)) {
 	 *     writer.write(value, xml);
 	 * }
-	 * }
+ * } * * @param output the underlying output stream * @return a new {@code XMLStreamWriter} instance diff --git a/jenetics/src/main/java/io/jenetics/Alterer.java b/jenetics/src/main/java/io/jenetics/Alterer.java index a63658a6bb..34a854a706 100644 --- a/jenetics/src/main/java/io/jenetics/Alterer.java +++ b/jenetics/src/main/java/io/jenetics/Alterer.java @@ -29,7 +29,7 @@ * Alterers can be chained by appending a list of alterers with the * {@link io.jenetics.engine.Engine.Builder#alterers(Alterer, Alterer[])} method. * - *
{@code
+ * {@snippet lang="java":
  * final Engine engine = Engine
  *     .builder(gtf, ff)
  *     .alterers(
@@ -38,7 +38,7 @@
  *         new MeanAlterer<>(0.2))
  *     .build();
  * final EvolutionStream stream = engine.stream();
- * }
+ * } * * The order of the alterer calls is: Crossover, Mutation and MeanAlterer. * diff --git a/jenetics/src/main/java/io/jenetics/AnyChromosome.java b/jenetics/src/main/java/io/jenetics/AnyChromosome.java index 8a4470f536..f46904794d 100644 --- a/jenetics/src/main/java/io/jenetics/AnyChromosome.java +++ b/jenetics/src/main/java/io/jenetics/AnyChromosome.java @@ -32,7 +32,7 @@ * {@code Chromosome} implementation, which allows to create genes without * explicit implementing the {@code Chromosome} interface. * - *
{@code
+ * {@snippet lang="java":
  * public class LastMonday {
  *
  *     // First monday of 2015.
@@ -70,7 +70,7 @@
  *     }
  *
  * }
- * }
+ * } * * The full example above shows how the {@code AnyChromosome} is used * to use it for an allele-type with no predefined gene- and chromosome type. diff --git a/jenetics/src/main/java/io/jenetics/AnyGene.java b/jenetics/src/main/java/io/jenetics/AnyGene.java index 995aaf5c0f..e8d64f1e5f 100644 --- a/jenetics/src/main/java/io/jenetics/AnyGene.java +++ b/jenetics/src/main/java/io/jenetics/AnyGene.java @@ -35,7 +35,7 @@ * {@code Gene} implementation, which allows to create genes without explicit * implementing the {@code Gene} interface. * - *
{@code
+ * {@snippet lang="java":
  * class Main {
  *     // First monday of 2015.
  *     private static final LocalDate MIN_MONDAY = LocalDate.of(2015, 1, 5);
@@ -51,7 +51,7 @@
  *     // gene.newInstance(), are calling the 'newRandomMonday' method.
  *     final AnyGene gene = AnyGene.of(Main::nextRandomMonday);
  * }
- * }
+ * } * The example above shows how to create {@code LocalDate} genes from a random * {@code LocalDate} supplier. It also shows how to implement a restriction on * the created dates. The usage of the {@code AnyGene} class is useful for diff --git a/jenetics/src/main/java/io/jenetics/CharacterChromosome.java b/jenetics/src/main/java/io/jenetics/CharacterChromosome.java index f99f0dd58f..5a30aa5562 100644 --- a/jenetics/src/main/java/io/jenetics/CharacterChromosome.java +++ b/jenetics/src/main/java/io/jenetics/CharacterChromosome.java @@ -123,7 +123,7 @@ public CharacterChromosome newInstance() { * by applying the given mapper function {@code f}. The mapped gene values * are then wrapped into a newly created chromosome. * - *
{@code
+	 * {@snippet lang="java":
 	 * final CharacterChromosome chromosome = ...;
 	 * final CharacterChromosome uppercase = chromosome.map(Main::uppercase);
 	 *
@@ -133,7 +133,7 @@ public CharacterChromosome newInstance() {
 	 *     }
 	 *     return values;
 	 * }
-	 * }
+ * } * * @since 6.1 * diff --git a/jenetics/src/main/java/io/jenetics/Chromosome.java b/jenetics/src/main/java/io/jenetics/Chromosome.java index 68854425ba..7f0d6d5dde 100644 --- a/jenetics/src/main/java/io/jenetics/Chromosome.java +++ b/jenetics/src/main/java/io/jenetics/Chromosome.java @@ -83,17 +83,17 @@ default boolean isValid() { * Casts this {@code Chromosome} to an instance of type {@code C}. * This is a convenient method for an ordinary cast and allows seamless * method-chaining. Instead of - *
{@code
+	 * {@snippet lang="java":
 	 * final Genotype gt = ...
 	 * final int count = ((BitChromosome)gt.chromosome()).bitCount()
-	 * }
+ * } * you can write - *
{@code
+	 * {@snippet lang="java":
 	 * final Genotype gt = ...
 	 * final int count = gt.chromosome()
 	 *     .as(BitChromosome.class)
 	 *     .bitCount()
-	 * }
+ * } * This may lead to a more elegant programming style in some cases. * * @since 3.7 diff --git a/jenetics/src/main/java/io/jenetics/DoubleChromosome.java b/jenetics/src/main/java/io/jenetics/DoubleChromosome.java index 45efff4276..82fc65585b 100644 --- a/jenetics/src/main/java/io/jenetics/DoubleChromosome.java +++ b/jenetics/src/main/java/io/jenetics/DoubleChromosome.java @@ -97,7 +97,7 @@ public DoubleChromosome newInstance() { * by applying the given mapper function {@code f}. The mapped gene values * are then wrapped into a newly created chromosome. * - *
{@code
+	 * {@snippet lang="java":
 	 * final DoubleChromosome chromosome = ...;
 	 * final DoubleChromosome normalized = chromosome.map(Main::normalize);
 	 *
@@ -108,7 +108,7 @@ public DoubleChromosome newInstance() {
 	 *     }
 	 *     return values;
 	 * }
-	 * }
+ * } * * @since 6.1 * diff --git a/jenetics/src/main/java/io/jenetics/EliteSelector.java b/jenetics/src/main/java/io/jenetics/EliteSelector.java index 4672680556..3a7da1f28b 100644 --- a/jenetics/src/main/java/io/jenetics/EliteSelector.java +++ b/jenetics/src/main/java/io/jenetics/EliteSelector.java @@ -38,14 +38,14 @@ * A problem with elitism is that it may cause the GA to converge to a local * optimum, so pure elitism is a race to the nearest local optimum. * - *
{@code
+ * {@snippet lang="java":
  * final Selector selector = new EliteSelector<>(
  *     // Number of best individuals preserved for next generation: elites
  *     3,
  *     // Selector used for selecting rest of population.
  *     new RouletteWheelSelector<>()
  * );
- * }
+ * } * * @author Franz Wilhelmstötter * @version 5.0 diff --git a/jenetics/src/main/java/io/jenetics/EnumGene.java b/jenetics/src/main/java/io/jenetics/EnumGene.java index fed9495c7f..60e2d31b27 100644 --- a/jenetics/src/main/java/io/jenetics/EnumGene.java +++ b/jenetics/src/main/java/io/jenetics/EnumGene.java @@ -36,22 +36,22 @@ *

* The following code shows how to create a combinatorial genotype factory which * can be used when creating an {@link io.jenetics.engine.Engine} instance. - *
{@code
+ * {@snippet lang="java":
  * final ISeq alleles = ISeq.of(1, 2, 3, 4, 5, 6, 7, 8);
  * final Factory>> gtf = Genotype.of(
  *     PermutationChromosome.of(alleles)
  * );
- * }
+ * } * * The following code shows the assurances of the {@code EnumGene}. - *
{@code
+ * {@snippet lang="java":
  * final ISeq alleles = ISeq.of(1, 2, 3, 4, 5, 6, 7, 8);
  * final EnumGene gene = new EnumGene<>(5, alleles);
  *
  * assert(gene.alleleIndex() == 5);
  * assert(gene.allele() == gene.validAlleles().get(5));
  * assert(gene.validAlleles() == alleles);
- * }
+ * } * * @see PermutationChromosome * @see PartiallyMatchedCrossover diff --git a/jenetics/src/main/java/io/jenetics/Genotype.java b/jenetics/src/main/java/io/jenetics/Genotype.java index 49ac0813be..bab7462dd8 100644 --- a/jenetics/src/main/java/io/jenetics/Genotype.java +++ b/jenetics/src/main/java/io/jenetics/Genotype.java @@ -50,14 +50,14 @@ * a chromosome have the same constraints; e.g., the same min- and max values * for the genes value. * - *
{@code
+ * {@snippet lang="java":
  * final Genotype genotype = Genotype.of(
  *     DoubleChromosome.of(0.0, 1.0, 8),
  *     DoubleChromosome.of(1.0, 2.0, 10),
  *     DoubleChromosome.of(0.0, 10.0, 9),
  *     DoubleChromosome.of(0.1, 0.9, 5)
  * );
- * }
+ * } * The code snippet above creates a genotype with the same structure as shown in * the figure above. In this example the {@link DoubleGene} has been chosen as * a gene type. @@ -132,10 +132,10 @@ public int length() { /** * Return the first chromosome. This is an alias for - *
{@code
+	 * {@snippet lang="java":
 	 * final Genotype; gt = ...
 	 * final Chromosome chromosome = gt.get(0);
-	 * }
+ * } * * @since 5.2 * @@ -148,10 +148,10 @@ public Chromosome chromosome() { /** * Return the first {@link Gene} of the first {@link Chromosome} of this * {@code Genotype}. This is an alias for - *
{@code
+	 * {@snippet lang="java":
 	 * final Genotype gt = ...
 	 * final DoubleGene gene = gt.get(0).get(0);
-	 * }
+ * } * * @since 5.2 * @@ -268,10 +268,10 @@ public static > Genotype of( * for easily creating a gene matrix. The following example will * create a 10x5 {@code DoubleGene} matrix. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Genotype gt = Genotype
 	 *     .of(DoubleChromosome.of(0.0, 1.0, 10), 5);
-	 * }
+ * } * * @since 3.0 * diff --git a/jenetics/src/main/java/io/jenetics/IntegerChromosome.java b/jenetics/src/main/java/io/jenetics/IntegerChromosome.java index 103a60e794..f99d613b36 100644 --- a/jenetics/src/main/java/io/jenetics/IntegerChromosome.java +++ b/jenetics/src/main/java/io/jenetics/IntegerChromosome.java @@ -95,7 +95,7 @@ public IntegerChromosome newInstance() { * by applying the given mapper function {@code f}. The mapped gene values * are then wrapped into a newly created chromosome. * - *
{@code
+	 * {@snippet lang="java":
 	 * final IntegerChromosome chromosome = ...;
 	 * final IntegerChromosome halved = chromosome.map(Main::half);
 	 *
@@ -105,7 +105,7 @@ public IntegerChromosome newInstance() {
 	 *     }
 	 *     return values;
 	 * }
-	 * }
+ * } * * @since 6.1 * diff --git a/jenetics/src/main/java/io/jenetics/LongChromosome.java b/jenetics/src/main/java/io/jenetics/LongChromosome.java index 1f3188f0e9..8ced65d5fb 100644 --- a/jenetics/src/main/java/io/jenetics/LongChromosome.java +++ b/jenetics/src/main/java/io/jenetics/LongChromosome.java @@ -99,7 +99,7 @@ public LongChromosome newInstance() { * by applying the given mapper function {@code f}. The mapped gene values * are then wrapped into a newly created chromosome. * - *
{@code
+	 * {@snippet lang="java":
 	 * final LongChromosome chromosome = ...;
 	 * final LongChromosome halved = chromosome.map(Main::half);
 	 *
@@ -109,7 +109,7 @@ public LongChromosome newInstance() {
 	 *     }
 	 *     return values;
 	 * }
-	 * }
+ * } * * @since 6.1 * diff --git a/jenetics/src/main/java/io/jenetics/Optimize.java b/jenetics/src/main/java/io/jenetics/Optimize.java index bf5ae4c0ee..9367d1f0a8 100644 --- a/jenetics/src/main/java/io/jenetics/Optimize.java +++ b/jenetics/src/main/java/io/jenetics/Optimize.java @@ -61,19 +61,19 @@ int compare(final T a, final T b) { * to make it {@code null}-friendly, you can wrap it with the * {@link Comparator#nullsFirst(Comparator)} method. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Comparator comparator = nullsFirst(Optimize.MAXIMUM::compare);
 	 * assertEquals(comparator.compare(null, null), 0);
 	 * assertEquals(comparator.compare(null, 4), -1);
 	 * assertEquals(comparator.compare(4, null), 1);
-	 * }
+ * } * or - *
{@code
+	 * {@snippet lang="java":
 	 * final Comparator comparator = nullsFirst(Optimize.MINIMUM::compare);
 	 * assertEquals(comparator.compare(null, null), 0);
 	 * assertEquals(comparator.compare(null, 4), -1);
 	 * assertEquals(comparator.compare(4, null), 1);
-	 * }
+ * } * * @param the comparable type * @param a the first object to be compared. @@ -91,10 +91,10 @@ int compare(final T a, final T b) { * sorted in descending order, according to the given definition * of better and worse. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Population population = ...
 	 * population.sort(Optimize.MINIMUM.descending());
-	 * }
+ * } * * The code example above will populationSort the population according its * fitness values in ascending order, since lower values are better @@ -113,10 +113,10 @@ public > Comparator descending() { * sorted in ascending order, according to the given definition * of better and worse. * - *
{@code
+	 * {@snippet lang="java":
 	 * final Population population = ...
 	 * population.sort(Optimize.MINIMUM.ascending());
-	 * }
+ * } * * The code example above will populationSort the population according its * fitness values in descending order, since lower values are better @@ -148,11 +148,11 @@ public > C best(final C a, final C b) { * Return a {@code null}-friendly function which returns the best element of * two values. E.g. * - *
{@code
+	 * {@snippet lang="java":
 	 * assertNull(Optimize.MAXIMUM.best().apply(null, null));
 	 * assertEquals(Optimize.MAXIMUM.best().apply(null, 4), (Integer)4);
 	 * assertEquals(Optimize.MAXIMUM.best().apply(6, null), (Integer)6);
-	 * }
+ * } * * @see #best(Comparable, Comparable) * @@ -189,11 +189,11 @@ public > C worst(final C a, final C b) { * Return a {@code null}-friendly function which returns the worst element * of two values. E.g. * - *
{@code
+	 * {@snippet lang="java":
 	 * assertNull(Optimize.MAXIMUM.worst().apply(null, null));
 	 * assertEquals(Optimize.MAXIMUM.worst().apply(null, 4), (Integer)4);
 	 * assertEquals(Optimize.MAXIMUM.worst().apply(6, null), (Integer)6);
-	 * }
+ * } * * @see #worst(Comparable, Comparable) * diff --git a/jenetics/src/main/java/io/jenetics/PartialAlterer.java b/jenetics/src/main/java/io/jenetics/PartialAlterer.java index e0e7fb4243..068841e799 100644 --- a/jenetics/src/main/java/io/jenetics/PartialAlterer.java +++ b/jenetics/src/main/java/io/jenetics/PartialAlterer.java @@ -33,7 +33,7 @@ /** * This alterer wraps a given alterer which works on a given section of the * genotype's chromosomes. - *
{@code
+ * {@snippet lang="java":
  * // The genotype prototype, consisting of 4 chromosomes
  * final Genotype gtf = Genotype.of(
  *     DoubleChromosome.of(0, 1),
@@ -55,7 +55,7 @@
  *         new GaussianMutator<>()
  *     )
  *     .build();
- * }
+ * } * * If you are using chromosome indices which are greater or equal than the * number of chromosomes defined in the genotype, a diff --git a/jenetics/src/main/java/io/jenetics/PermutationChromosome.java b/jenetics/src/main/java/io/jenetics/PermutationChromosome.java index 1653e8eae6..e63bc91aa1 100644 --- a/jenetics/src/main/java/io/jenetics/PermutationChromosome.java +++ b/jenetics/src/main/java/io/jenetics/PermutationChromosome.java @@ -47,7 +47,7 @@ * This chromosome can be used to model permutations of a given (sub) set of * alleles. * - *
{@code
+ * {@snippet lang="java":
  * final ISeq alleles = ISeq.of("one", "two", "three", "four", "five");
  *
  * // Create a new randomly permuted chromosome from the given alleles.
@@ -65,7 +65,7 @@
  * // > two|one|four|five|three
  * // > three|one|five
  * // > five|three|one
- * }
+ * } * * Usable {@link Alterer} for this chromosome: *