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

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

View File

@ -1,22 +1,39 @@
package de.kneitzel;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
/**
* Starting point of the JavaApp
* Entry point for the JavaMavenApp application.
*
* <p>This final utility class is not instantiable and provides the application's main method.
* It coordinates startup behavior and is responsible for high-level program initialization.
*
* @since 1.0
*/
public final class JavaApp {
/**
* Private Constructor - we never create an instance!
* Private constructor to prevent instantiation of this utility class.
*
* <p>The class only exposes static behavior and should never be instantiated.
*/
private JavaApp() {}
/**
* Entry point of the application.
* @param args Commandline parameters.
* Application entry point.
*
* <p>This method initializes a {@code Greeting} instance and writes its string representation
* to standard output. The method does not parse or use {@code args} currently; they are
* preserved for future extensions.
*
* @param args the command-line arguments supplied to the application; must not be {@code null}.
* Currently unused and preserved for future extensions.
*/
public static void main(@NotNull final String[] args) {
static void main(@NotNull final String[] args) {
// Validate the parameter and reference it to avoid unused-parameter inspections.
Objects.requireNonNull(args, "args must not be null");
final Greeting greeting = new Greeting(null);
System.out.println(greeting);
}