Mgnt Utilities
MgntUtils is an open-source Java library that provides:
The Javadoc API is available here: MgntUtils Javadoc API
Stacktrace Filtering
One of the most popular features of MgntUtils is advanced stacktrace filtering. The primary API is TextUtils.getStacktrace(), which accepts either a Throwable or a raw String. It removes framework noise (such as application server and library internals), making logs significantly more readable and reducing their size.
Filtering is configured via a predefined list of relevant package prefixes, allowing you to focus only on application-level code.
Key capabilities:
ThrowableString input (e.g., logs, remote services)Why String-based filtering matters: Unlike typical solutions that operate only on exceptions, MgntUtils can process raw stacktrace strings. This enables usage beyond in-process error handling:
Infrastructure-level integration:
This feature can be integrated transparently into Spring Boot applications without changing existing code.
See: Zero-Code-Change Stacktrace Filtering for Spring Boot: An Infrastructure-Level Integration.
Human-Readable Time Intervals
The methods TextUtils.parseStringToTimeInterval() and TextUtils.parseStringToDuration() convert strings like "5d", "4h", or "30m" directly into long milliseconds or java.time.Duration values, making time-based configuration far more maintainable than raw numeric values.
Unicode Conversion
The StringUnicodeEncoderDecoder class converts strings to Unicode escape sequences (e.g., Hello → \u0048\u0065\u006c\u006c\u006f) and back. This is useful for debugging encoding issues, handling special characters and emojis and working with non-Latin scripts such as Hebrew, Arabic, Slavic languages, Chinese, and others.
Silent Numeric Parsing
Utility methods for parsing strings into numeric types (e.g., Integer, Long, Double) without throwing NumberFormatException. Instead, they return a default value or null when parsing fails, avoiding boilerplate try-catch blocks.
Version Comparison
The library provides a Version type and VersionRange support, enabling easy comparison of software versions and checking whether a version falls within a given range. It also supports checking the intersection of version ranges.
JSON Parsing
Simple JSON serialization and deserialization utilities for basic use cases.
Web and File Utilities
WebUtils includes a method for chunked reading of HTTP request content that can auto-throttle to match the client’s consumption speed.All other utilities in this library solve individual, well-defined problems. What follows is different in kind: it is a fundamental architectural pattern and by far the most significant part of this library. It is packaged as a lightweight micro-framework — two classes — that provides the infrastructure for a self-registering factory pattern. The library ships this infrastructure along with a complete, runnable example. The broader architectural pattern it enables — resolving an N × M extensibility problem across multiple data types and processing stages without modifying existing code — is not part of the library itself, but is documented in detail in Infrastructure for Extensible Multi-Stage Workflows Across Multiple Data Types and demonstrated in a separate companion project. This article should be considered required reading alongside this section.
The framework implementation is located in package com.mgnt.lifecycle.management. It provides infrastructure for factories whose components automatically register themselves during initialization — similar in spirit to an Inversion of Control container, but without the framework overhead and with no external dependencies. Implementation classes are factory-aware: this eliminates manual factory-population logic and centralized registration maps entirely — as long as a concrete implementation is instantiated, it becomes available through the factory.
The package-level Javadoc contains a detailed explanation of the design and a complete, runnable example included with the library source.
See the Javadoc for details:
Self-Populating Factory package documentation
This README and the library Javadoc provide a solid overview of what MgntUtils is and how to start using it. In addition, there is a series of articles about the library and its features that go deeper into each major utility and the Self-Populating Factory pattern. These articles should be treated as integral parts of the library’s documentation and are especially useful for understanding architectural uses and advanced setups.
You can find all of these articles in the Featured section of my LinkedIn profile:
https://www.linkedin.com/in/michael-gantman-9661521/details/featured/
Java Stacktrace filtering utility
Focuses on the library’s most popular feature: TextUtils.getStacktrace(). It explains how to use it for cleaner logs and how to configure package-based filtering to keep important stack frames and remove noise.
Zero-Code-Change Stacktrace Filtering for Spring Boot: An Infrastructure-Level Integration
This is a follow up article to Java Stacktrace filtering utility. The first article explains what the feature is and how to configure it. This one explains how to transparently integrate it into Spring Boot project without any code base changes required. It is truly a game changer. It is a small one time effort and completely transparent to developers, but carries a huge benefit
Parsing human-readable Strings to Time Intervals - no more crazy numbers in milliseconds
Explores the TextUtils.parseStringToTimeInterval() and TextUtils.parseStringToDuration() utilities in detail, showing how human-readable time-interval strings (like "5d", "4h", "30m") can replace hard-to-read numeric values in configuration and code.
String to Unicode converter utility
Explores StringUnicodeEncoderDecoder and shows how to convert strings to Unicode escape sequences and back. This is especially useful when debugging encoding issues, inspecting Unicode-encoded configuration, or working with non-Latin languages.
This article underscores the fact that beyond its collection of utilities, this library provides a foundation for a powerful architectural design pattern that can be reused across many projects.
MgntUtils is available on Maven Central:
<dependency>
<groupId>com.github.michaelgantman</groupId>
<artifactId>MgntUtils</artifactId>
<version>1.7.0.9</version>
</dependency>
If you also want Javadoc and sources for your IDE:
<dependency>
<groupId>com.github.michaelgantman</groupId>
<artifactId>MgntUtils</artifactId>
<version>1.7.0.9</version>
<classifier>javadoc</classifier>
</dependency>
<dependency>
<groupId>com.github.michaelgantman</groupId>
<artifactId>MgntUtils</artifactId>
<version>1.7.0.9</version>
<classifier>sources</classifier>
</dependency>
If you have any feedback, feel free to drop me a note at michael_gantman@yahoo.com