Skip to content

aryanm9026/Adaptive-Boolean-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdaptiveBoolean

Release Java CI License: MIT

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.

Features

  • Extremely Fast: Utilizes O(1) Set lookups for zero-latency parsing.
  • Lenient Parsing: Automatically handles whitespace, casing, and common colloquialisms (e.g., "yep", "nah", "1", "0").
  • Fail-Fast: Throws an IllegalArgumentException on invalid or empty inputs, ensuring your application state remains predictable.
  • Ultra-Lightweight: Zero external dependencies.

Installation

This library is published via JitPack. You can easily pull it into any Java project using Gradle or Maven.

Gradle (build.gradle)

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'
}

Maven (pom.xml)

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>

Usage

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"); 
    }
}

Supported Values

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"

Local Development & Testing

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 test

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages