Skip to content

klojang4j/klojang-convert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Klojang Invoke

Klojang Convert contains classes aimed at converting values of one type into values of another type. The Morph class is capable of converting a wide variety of input types to a wide variety of output types.

Klojang Invoke is mainly intended as a supporting library for Klojang Invoke where it is used to enable loosely typed bean writing.

Getting Started

To use Klojang Convert, add the following dependency to your Maven POM file:

<dependency>
    <groupId>org.klojang</groupId>
    <artifactId>klojang-convert</artifactId>
    <version>24.1.0</version>
</dependency>

or Gradle build script:

implementation group: 'org.klojang', name: 'klojang-convert', version: '24.1.0'

Documentation

The Javadocs for Klojang Convert can be found here.

The latest coverage reports can be found here.

Conversion Table

Input Value (val) Target Type Output Value / Transformation
null primitive primitive default (0, 0L '\0', false, etc.)
null object null
instance of T T (T) val
Integer int (int) val (and so on for other primitive wrappers)
byte[] String new String(val, StandardCharsets.UTF_8)
char[] String new String(val)
? String val.toString()
T[] U[] for-each t: Morph.convert(t, U.class) (recursive call)
Collection<T> U[] for-each t: Morph.convert(t, U.class) (recursive call)
IntList *) U[] for-each i: Morph.convert(i, U.class) (recursive call)
String byte[] val.getBytes(StandardCharsets.UTF_8)
String char[] val.toCharArray()
? U[] new U[] { val }

*) org.klojang.util.collection.IntList

About

Data & Type Conversion Utilities

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages