Package com.guinetik.examples
Class HelloTerminal
java.lang.Object
com.guinetik.examples.HelloTerminal
A comprehensive example class demonstrating Terminal Javadocs JXR styling
with Prism.js syntax highlighting.
This class showcases various Java language features including:
- Generics and type parameters
- Lambda expressions and method references
- Stream API operations
- Optional handling
- Exception handling patterns
- Inner classes and enums
- Annotations
Usage Example
HelloTerminal terminal = new HelloTerminal("World");
terminal.displayGreeting();
terminal.runAsyncTask("Process data");
- Since:
- 2024
- Version:
- 1.0.0
- Author:
- guinetik
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the status of the terminal.static classRepresents the result of an asynchronous task. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new HelloTerminal with a default name.HelloTerminal(String name) Creates a new HelloTerminal with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionaddHandler(Function<String, String> handler) Registers a message handler function.voidDisplays a colorful greeting to the terminal.<T> Optional<T>Finds a value by key with optional default.generateSequence(int count) Generates a sequence of numbers with transformations.Gets the last activity timestamp.Gets the current status.static voidMain entry point for testing the HelloTerminal class.processMessage(String message) Processes a message through all registered handlers.runAsyncTask(String taskDescription) Runs an asynchronous task with the given description.
-
Field Details
-
DEFAULT_GREETING
The default greeting template- See Also:
-
ANSI_GREEN
ANSI escape code for green text- See Also:
-
ANSI_RESET
ANSI escape code to reset text color- See Also:
-
-
Constructor Details
-
HelloTerminal
public HelloTerminal()Creates a new HelloTerminal with a default name. -
HelloTerminal
Creates a new HelloTerminal with the specified name.- Parameters:
name- the target name for greetings- Throws:
IllegalArgumentException- if name is null or empty
-
-
Method Details
-
displayGreeting
public void displayGreeting()Displays a colorful greeting to the terminal.The greeting is formatted using ANSI escape codes for terminal color support.
-
addHandler
Registers a message handler function.- Parameters:
handler- the handler function to register- Returns:
- this instance for method chaining
-
processMessage
Processes a message through all registered handlers.- Parameters:
message- the message to process- Returns:
- the processed message after all handlers have been applied
-
runAsyncTask
Runs an asynchronous task with the given description.- Parameters:
taskDescription- description of the task to run- Returns:
- a CompletableFuture containing the task result
-
findValue
Finds a value by key with optional default.- Type Parameters:
T- the type of value to find- Parameters:
key- the key to search fordefaultValue- the default value if not found- Returns:
- an Optional containing the found value or default
-
generateSequence
Generates a sequence of numbers with transformations.- Parameters:
count- the number of elements to generate- Returns:
- a list of formatted number strings
-
getStatus
Gets the current status.- Returns:
- the current status
-
getLastActivity
Gets the last activity timestamp.- Returns:
- the last activity time
-
main
Main entry point for testing the HelloTerminal class.- Parameters:
args- command line arguments (first argument used as name)
-