Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move override annotations to inner classes of @ConfigMapping #252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions api/src/main/java/jakarta/config/ConfigDefault.java

This file was deleted.

30 changes: 30 additions & 0 deletions api/src/main/java/jakarta/config/ConfigMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,34 @@
* @return a {@link String} representation of a configuration path.
*/
String path() default "";

/**
* Override the configuration member name.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD })
@interface Name {
/**
* The name of the configuration member name. Must not be empty.
*
* @return the configuration member name
*/
String value();
}

/**
* Specify the default value of a configuration member.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD })
@interface Default {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should provide specialized Default types like @DefaultInt, @DefaultBoolean, etc, or as a member intValue(), booleanValue(). The annotation / member to use has to match the declared type. If another annotation / member is used we could throw a validation error.

This would avoid having to come up with a Conversion strategy from String to something and provide type safety for defaults definition

Copy link
Contributor

@jansupol jansupol May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One cannot create an extra annotation for each java Type. Rather, the Default value can be a class of data converter. While we have not discussed the converters yet, it looks like it should be discussed before continuing with the @Default annotation.

/**
* The default value of the member.
*
* @return the default value as a string
*/
String value();
}
}
22 changes: 0 additions & 22 deletions api/src/main/java/jakarta/config/ConfigName.java

This file was deleted.