---
title: 'Code Snippets in Java API Doku geplant (JEP 413)'
url: 'https://tutego.de/blog/javainsel/2021/09/code-snippets-in-java-api-doku-geplant-jep-413'
markdown: 'https://tutego.de/blog/javainsel/2021/09/code-snippets-in-java-api-doku-geplant-jep-413.md'
date: '2021-09-06'
description: 'Interessantes Feature, was die Javadoc doch dicker machen könnte. Geplant: /** The following code shows how to use {@code Optional.isPresent}: {@snippet : if (v.isPresent()) { System.out.println("v: " + v.get()); } } */ Interessant wird das ganze durch Includes (wie bei Asciidoc): ```java /*…'
taxonomy:
  category:
    - Allgemein
---

# Code Snippets in Java API Doku geplant (JEP 413)

![Illustration einer tropischen Insel mit Palmen und einem hohen Berg](https://tutego.de/blog/javainsel/user/themes/tutego/images/insel-cover.jpg)# Java Blog für Programmierer

[Java Blog für Programmierer](https://tutego.de/blog/javainsel/)

## Code Snippets in Java API Doku geplant (JEP 413)

06.09.2021 · [Christian Ullenboom](https://tutego.de/blog/javainsel/author/admin/)

Interessantes Feature, was die Javadoc doch dicker machen könnte. Geplant:

```text

```

/\*\*

- The following code shows how to use {@code `Optional`.`isPresent`}:
- {@snippet : ```java

    ```
- if (v.isPresent()) {
- System.out.println("v: " + v.get()); ```

    ```
- }
- } \*/ ```text

    ```

Interessant wird das ganze durch Includes (wie bei Asciidoc):

```

```java
/**
 * The following code shows how to use {@code Optional.isPresent}:
 * {@snippet file="ShowOptional.java" region="example"}
 */
```

```text
Dinge können zum Beispiel fett hervorgehoben werden:
```

```java
/**
 * A simple program.
 * {@snippet :
 * class HelloWorld {
 *     public static void main(String... args) {
 *         System.out.println("Hello World!");      // @highlight substring="println"
 *     }
 * }
 * }
 */
```

```text

Und Texte können ersetzt werden:
```

```java
/**
 * A simple program.
 * {@snippet :
 * class HelloWorld {
 *     public static void main(String... args) {
 *         System.out.println("Hello World!");  // @replace regex='".*"' replacement="..."
 *     }
 * }
 * }
 */
```

Ziemlich wild, würdet ihr so was nutzen für eure Javadoc? Ich nutzte bisher immer Testfälle, um eine API zu zeigen und auch zu lernen.

Zum Weiterlesen:

Kategorien: [Allgemein](https://tutego.de/blog/javainsel/category/allgemein/)

[← Alle Beiträge](https://tutego.de/blog/javainsel/)

---

## Navigation

- Next: [Roadmap für Spring 6](https://tutego.de/blog/javainsel/2021/09/roadmap-fuer-spring-6.md)
