-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register implicit converters for reflection
- Loading branch information
Showing
8 changed files
with
227 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ImplicitConverters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.quarkus.it.smallrye.config; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigMapping(prefix = "implicit.converters") | ||
public interface ImplicitConverters { | ||
@WithDefault("value") | ||
Optional<ImplicitOptional> optional(); | ||
|
||
@WithDefault("value") | ||
List<ImplicitElement> list(); | ||
|
||
Map<String, ImplicitValue> map(); | ||
|
||
class ImplicitOptional { | ||
private final String value; | ||
|
||
public ImplicitOptional(final String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public static ImplicitOptional of(String value) { | ||
return new ImplicitOptional("converted"); | ||
} | ||
} | ||
|
||
class ImplicitElement { | ||
private final String value; | ||
|
||
public ImplicitElement(final String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public static ImplicitElement of(String value) { | ||
return new ImplicitElement("converted"); | ||
} | ||
} | ||
|
||
class ImplicitValue { | ||
private final String value; | ||
|
||
public ImplicitValue(final String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public static ImplicitValue of(String value) { | ||
return new ImplicitValue("converted"); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...allrye-config/src/main/java/io/quarkus/it/smallrye/config/ImplicitConvertersResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.it.smallrye.config; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
@Path("/implicit/converters") | ||
public class ImplicitConvertersResource { | ||
@Inject | ||
ImplicitConverters implicitConverters; | ||
|
||
@GET | ||
@Path("/optional") | ||
public Response optional() { | ||
return Response.ok(implicitConverters.optional().get().getValue()).build(); | ||
} | ||
|
||
@GET | ||
@Path("/list") | ||
public Response list() { | ||
return Response.ok(implicitConverters.list().get(0).getValue()).build(); | ||
} | ||
|
||
@GET | ||
@Path("/map") | ||
public Response map() { | ||
return Response.ok(implicitConverters.map().get("key").getValue()).build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...sts/smallrye-config/src/test/java/io/quarkus/it/smallrye/config/ImplicitConvertersIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.it.smallrye.config; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class ImplicitConvertersIT extends ImplicitConvertersTest { | ||
|
||
} |
Oops, something went wrong.