Enhance documentation for Greeting and JavaApp classes

This commit is contained in:
Konrad Neitzel
2025-11-30 14:22:17 +01:00
parent 78f4406824
commit e722e5dde4
2 changed files with 44 additions and 18 deletions
+22 -13
View File
@@ -2,51 +2,60 @@ package de.kneitzel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Simple Greeting class for some demonstration.
* Simple greeting value object used for demonstration purposes.
*
* <p>Instances are immutable and encapsulate a single name that is used when generating
* a greeting string via {@link #toString()}.
*/
public class Greeting {
/**
* Default name that should be greeted if no name is given.
* Default name used when no explicit name is provided. The default value is the German
* word {@code "Welt"} ("world").
*/
public static final String DEFAULT_NAME = "Welt";
/**
* Name that should be greeted
* <p>
* Cannot be null.
* </p>
* The name to greet. Never {@code null}.
*/
@NotNull
private final String name;
/**
* Gets the name that should be greeted.
* @return Name that should be greeted.
* Returns the name that will be greeted.
*
* @return the name to greet; never {@code null}.
*/
public @NotNull String getName() {
return name;
}
/**
* Creates a new Instance of Greeting which greets the "World".
* Creates a new {@code Greeting} instance that greets the default name ({@link #DEFAULT_NAME}).
*/
public Greeting() {
this(null);
}
/**
* Creates a new instance of Greeting to greet the given name.
* @param name Name that should be greeted by Greeting.
* Creates a new {@code Greeting} instance for the given name.
*
* @param name the name to greet; may be {@code null} in which case {@link #DEFAULT_NAME}
* will be used instead.
*/
public Greeting(@Nullable final String name) {
this.name = name == null ? DEFAULT_NAME : name;
}
/**
* String representation of this instance.
* @return String representation of "Hello name!"
* Returns a greeting string for this instance.
*
* <p>The greeting is formatted in German as {@code "Hallo <name>!"}. The returned string is
* never {@code null}.
*
* @return a greeting such as {@code "Hallo Welt!"}; never {@code null}.
*/
@NotNull
@Override