A lightweight, high-performance Java utility for parsing messy, human-centric string inputs into strict booleans.
Java's built-in Boolean.parseBoolean(String s) is notoriously strict and only returns true for the exact string "true". AdaptiveBoolean acts as a lenient, conversational parser—perfect for CLI applications, messy data streams, and rapid user input handling.
- Extremely Fast: Utilizes O(1)
Setlookups for zero-latency parsing. - Lenient Parsing: Automatically handles whitespace, casing, and common colloquialisms (e.g.,
"yep","nah","1","0"). - Fail-Fast: Throws an
IllegalArgumentExceptionon invalid or empty inputs, ensuring your application state remains predictable. - Ultra-Lightweight: Zero external dependencies.
This library is published via JitPack. You can easily pull it into any Java project using Gradle or Maven.
Step 1. Add the JitPack repository to your build file:
repositories {
mavenCentral()
maven { url '[https://jitpack.io](https://jitpack.io)' }
}Step 2. Add the dependency:
dependencies {
implementation 'com.github.aryanm9026:Adaptive-Boolean-Library:v1.0.1'
}Step 1. Add the JitPack repository:
<repositories>
<repository>
<id>jitpack.io</id>
<url>[https://jitpack.io](https://jitpack.io)</url>
</repository>
</repositories>Step 2. Add the dependency:
<dependency>
<groupId>com.github.aryanm9026</groupId>
<artifactId>Adaptive-Boolean-Library</artifactId>
<version>v1.0.1</version>
</dependency>Import the utility and pass your string directly into the parse() method.
import org.aryanm9026.utils.AdaptiveBoolean;
public class Main {
public static void main(String[] args) {
// Evaluates to true
boolean isReady = AdaptiveBoolean.parse(" YeP ");
boolean isEnabled = AdaptiveBoolean.parse("1");
// Evaluates to false
boolean isDeclined = AdaptiveBoolean.parse("nah");
// Throws IllegalArgumentException
boolean isUnknown = AdaptiveBoolean.parse("maybe");
}
}The parser is completely case-insensitive and automatically trims leading/trailing whitespace.
Resolves to true |
Resolves to false |
|---|---|
"yes" |
"no" |
"y" |
"n" |
"true" |
"false" |
"t" |
"f" |
"1" |
"0" |
"ok" |
"nope" |
"sure" |
"nah" |
"yep" |
To clone this repository and run the JUnit test suite locally:
git clone [https://github.com/aryanm9026/Adaptive-Boolean-Library.git](https://github.com/aryanm9026/Adaptive-Boolean-Library.git)
cd Adaptive-Boolean-Library
./gradlew clean testThis project is licensed under the MIT License.