MgntUtils is an open-source Java library that provides:
- A collection of utility methods for common tasks that are either missing from or overly verbose in the standard Java API
- Self-Populating Factory Micro-Framework: The most architecturally significant part of this library — a micro-framework whose implementation classes automatically register themselves with their factory upon instantiation, eliminating manual registry maintenance and enabling a powerful N × M extensibility pattern described in the documentation below.
The Javadoc API is available here: MgntUtils Javadoc API
-
Stack Trace Filtering
One of the most popular features isTextUtils.getStacktrace(), which filters out “noise” from stack traces (such as application-server-related packages), making logs more readable and reducing log size. The filtering can be configured using package prefixes to specify which packages are important. -
Human-Readable Time Intervals
The methodsTextUtils.parseStringToTimeInterval()andTextUtils.parseStringToDuration()convert strings like"5d","4h", or"30m"directly intolongmilliseconds orjava.time.Durationvalues, making time-based configuration far more maintainable than raw numeric values. -
Unicode Conversion
TheStringUnicodeEncoderDecoderclass 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 throwingNumberFormatException. Instead, they return a default value ornullwhen parsing fails, avoiding boilerplate try-catch blocks. -
Version Comparison
The library provides aVersiontype andVersionRangesupport, 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
- Simple HTTP Client: A lightweight, easy-to-configure HTTP client suitable for repeated calls to the same URLs, such as in microservices communication. Configuration is reusable across multiple calls.
- HTTP Throttling:
WebUtilsincludes a method for chunked reading of HTTP request content that can auto-throttle to match the client’s consumption speed. - File I/O: Basic utilities for reading from and writing to files.
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 the article linked below and demonstrated in a separate companion project. That 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/
- MgntUtils Open Source Java library with stack trace filtering, Silent String parsing, Unicode converter and Version comparison
This general-purpose article introduces the library as a whole, lists its main features, and gives brief usage examples for each.
-
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. -
Parsing human-readable Strings to Time Intervals - no more crazy numbers in milliseconds
Explores theTextUtils.parseStringToTimeInterval()andTextUtils.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
ExploresStringUnicodeEncoderDecoderand 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. -
Infrastructure for Extensible Multi-Stage Workflows Across Multiple Data Types
This is the most in-depth article in the series. It can be viewed as a two-part piece:- Part 1 covers the Self-Populating Factory pattern in greater detail and walks through the runnable example included in the library.
- Part 2 shows how this pattern can be used to build extensible, multi-stage workflows for multiple data types, allowing you to “extend the flow length-wise and width-wise” (i.e., resolve an N × M matrix-like problem) without modifying existing code - just by adding new data types and stages.
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.6</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.6</version>
<classifier>javadoc</classifier>
</dependency><dependency>
<groupId>com.github.michaelgantman</groupId>
<artifactId>MgntUtils</artifactId>
<version>1.7.0.6</version>
<classifier>sources</classifier>
</dependency>If you have any feedback, feel free to drop me a note at michael_gantman@yahoo.com