forked from micronaut-projects/micronaut-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes alters property source processing such that the lower case hyphen separated version of a property name is all that is stored thus saving memory. This is consistent with Grails and Spring Boot. You can still define properties in camel case, however they are normalized when read from foo.barBaz into foo.bar-baz When reading properties with @value you should always use the lower case hyphen separated form.
- Loading branch information
1 parent
cb8a181
commit 125910b
Showing
51 changed files
with
408 additions
and
185 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
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
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
37 changes: 37 additions & 0 deletions
37
core/src/main/java/io/micronaut/core/convert/format/KeyFormat.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,37 @@ | ||
/* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.core.convert.format; | ||
import io.micronaut.core.naming.conventions.StringConvention; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
|
||
/** | ||
* Allows configuring the format of Map keys. | ||
* | ||
* @author Graeme Rocher | ||
* @since 1.0 | ||
*/ | ||
@Documented | ||
@Retention(RUNTIME) | ||
public @interface KeyFormat { | ||
/** | ||
* @return The string conversion to use | ||
*/ | ||
StringConvention value(); | ||
} |
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
73 changes: 73 additions & 0 deletions
73
core/src/main/java/io/micronaut/core/naming/conventions/StringConvention.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,73 @@ | ||
/* | ||
* Copyright 2018 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.core.naming.conventions; | ||
|
||
import io.micronaut.core.naming.NameUtils; | ||
|
||
/** | ||
* An enum representing different conventions for | ||
* | ||
* @author graemerocher | ||
* @since 1.0 | ||
*/ | ||
public enum StringConvention { | ||
/** | ||
* Camel case capitalized like class names | ||
* | ||
* Example: FooBar | ||
*/ | ||
CAMEL_CASE_CAPITALIZED, | ||
/** | ||
* Camel case, lower case first letter | ||
* | ||
* Example: fooBar | ||
*/ | ||
CAMEL_CASE, | ||
|
||
/** | ||
* Hyphenated, in lower case. Example foo-bar | ||
*/ | ||
HYPHENATED, | ||
|
||
/** | ||
* Hyphenated, in upper case. Example FOO_BAR | ||
*/ | ||
UNDER_SCORE_SEPARATED; | ||
|
||
/** | ||
* Format the string with this format | ||
* | ||
* @param str The string | ||
* @return The formatted string | ||
*/ | ||
public String format(String str) { | ||
return StringConvention.format(this, str); | ||
} | ||
|
||
public static String format(StringConvention convention, String str) { | ||
switch (convention) { | ||
case CAMEL_CASE: | ||
return NameUtils.camelCase(str); | ||
case HYPHENATED: | ||
return NameUtils.hyphenate(str); | ||
case UNDER_SCORE_SEPARATED: | ||
return NameUtils.environmentName(str); | ||
case CAMEL_CASE_CAPITALIZED: | ||
default: | ||
return NameUtils.camelCase(str, false); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.