CDI Converters

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

GroupId

GroupId

com.github.rmannibucau
ArtifactId

ArtifactId

cdi-converters
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

CDI Converters
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Source Code Management

Source Code Management

https://github.com/rmannibucau/cdi-converters

Download cdi-converters

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.rmannibucau/cdi-converters/ -->
<dependency>
    <groupId>com.github.rmannibucau</groupId>
    <artifactId>cdi-converters</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.rmannibucau/cdi-converters/
implementation 'com.github.rmannibucau:cdi-converters:1.0'
// https://jarcasting.com/artifacts/com.github.rmannibucau/cdi-converters/
implementation ("com.github.rmannibucau:cdi-converters:1.0")
'com.github.rmannibucau:cdi-converters:jar:1.0'
<dependency org="com.github.rmannibucau" name="cdi-converters" rev="1.0">
  <artifact name="cdi-converters" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.rmannibucau', module='cdi-converters', version='1.0')
)
libraryDependencies += "com.github.rmannibucau" % "cdi-converters" % "1.0"
[com.github.rmannibucau/cdi-converters "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.apache.deltaspike.core : deltaspike-core-api jar 0.3-incubating

provided (1)

Group / Artifact Type Version
org.apache.openejb : javaee-api jar 6.0-5

test (3)

Group / Artifact Type Version
org.apache.openejb : arquillian-openejb-embedded-4 jar 4.5.1
org.jboss.arquillian.junit : arquillian-junit-container jar 1.0.3.Final
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Build Status

Goal

Define converters (static method or not) then be able to use them for single object or collections through ObjectConverter interface.

Example

public static class LenConverter {
    // static method
    
    @Converter(in = In.class, out = Out.class)
    public static Out convert(final In in) {
        return new Out(in.value.length());
    }

    // or use completely CDI

    @Inject
    private Helper helper;

    @Converter(in = String.class, out = String.class)
    public String convert(final String in) {
        return helper.foo(in);
    }
}

then in another bean:

@Inject
@Converter(in = In.class, out = Out.class)
private ObjectConverter<In, Out> len;

// ...
assertEquals(3, len.to(new In("foo")).len);

Versions

Version
1.0