Skip to content

Kaktushose/proteus

Repository files navigation

Generic badge Java CI Release Deployment license-shield

Proteus

Proteus (named after the Greek shape-shifting sea god) is a modern, bidirectional type adapting library for Java.

Proteus proteus = Proteus.global();

// define types and mapper
Type<Integer> integerType = Type.of(Integer.class);
Type<String> stringType = Type.of(String.class);

// register mapper
proteus.map(integerType).to(stringType, Mapper.uni((source, context) -> MappingResult.lossless(String.valueOf(source))));

// attempt conversion
ConversionResult<String> result = proteus.convert(0, integerType, stringType);

// check result
switch (result) {
    case ConversionResult.Success<String>(String success, boolean _) -> System.out.println(success);
    case ConversionResult.Failure<?> failure -> System.out.println(failure.detailedMessage());
}

Features

  • Bidirectional, Multistep Type Conversion

  • Extensible & Threadsafe API

  • Shortest Path Usage & Path Caching

  • Comprehensive Error Messages

  • Framework-friendly Design

Download

Proteus is distributed via maven central. You can find the latest release here.

Gradle

repositories {
   mavenCentral()
}
dependencies {
   implementation("io.github.kaktushose:proteus:VERSION")
}

Maven

<dependency>
   <groupId>io.github.kaktushose</groupId>
   <artifactId>proteus</artifactId>
   <version>VERSION</version>
</dependency>

Contribution

If you think that something is missing, and you want to add it yourself, feel free to open a pull request. Please consider opening an issue first, so we can discuss if your changes fit to Proteus.