Package-level declarations
Overview
This package contains reusable utilities that support configuration handling, logging, and audio management. The central feature is a ConfigLoader class that automates the creation and loading of configuration files in .properties format, allowing each subsystem to define its own configuration model by implementing the Config interface. This ensures that each module can provide default configuration values while still allowing users to override them through editable files.
Key Components
ConfigLoader<U : Config>— Generic configuration loaderReads a properties file from a provided path.
If the file does not exist, creates the directory/file; writes default entries obtained from
factory(emptyMap()).getDefaultConfigFileEntries()and stores the file.Converts the loaded properties to
Map<String, String>and invokesfactory(configMap)to build the concrete configuration.Config— Interface for configuration implementationsContract that requires exposing
getDefaultConfigFileEntries(): Map<String, String>with the default values to write when the file does not exist.Environment— Centralized constantsDefines constants:
CONFIG_FOLDER,CORE_CONFIG_FILE,CLI_CONFIG_FILE,APP_CONFIG_FILE. The default directory is config and the default files arereversi-core.properties,reversi-cli.properties, andreversi-app.properties.PlainFormatter— Log message formatter for clean, readable console outputStdOutConsoleHandler— Console handler that writes to standard outputTracker— Tracking and analytics utilities for monitoring application behaviorUtils— General utility functions and extension methods
Responsibilities
Provide a simple and consistent mechanism to load/manage configuration files.
Ensure missing configuration files are created with default entries.
Expose reusable environment constants for other modules to locate configuration files.
Provide logging infrastructure with customizable formatters and handlers.
Supply utility functions used across multiple modules.
Manage audio playback and sound effects.
Notes
Modules such as
reversi-core,reversi-cli, andreversi-appshould provide an implementation ofConfigand pass a factory toConfigLoader.The default configuration file is plain text in Java Properties format, as this facilitates manual editing and debugging.
Types
Development tracker for monitoring application behavior.
Export format options for tracking data.
A plain formatter for logging that outputs the log level, source method name, and message.
Custom logging handler that outputs formatted log records to standard output with ANSI color codes. Different log levels are displayed in different colors for better readability.
Configuration for the DevTracker.
Data class representing a single tracking event.
Data class representing statistics for a specific tracked context.
Enum representing the types of tracking events that can be recorded.
Properties
Base data directory for configuration and logs.
CLI module configuration file path (reversi-cli.properties).
Configuration directory path containing all application configuration files.
Core module configuration file path (reversi-core.properties).
Per-run logs folder derived from current date (e.g., data/logs/log-YYYY-MM-DD-N).
Global development tracker instance for monitoring application behavior.
Functions
Lists all files in a resource directory, works both in IDE and JAR.
Loads a resource file from the classpath. Only use this if you really need a File object. For most cases, use getResource() directly.
Makes a path string by joining the given parts with the base game folder.
Sets the logger to log to a file with a name based on the current date. If a file with the same name already exists, a counter is added to the name.