-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to choose property catalog for EachProperty annotation
- Loading branch information
Showing
12 changed files
with
334 additions
and
3 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
core/src/main/java/io/micronaut/core/value/PropertyCatalog.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,40 @@ | ||
/* | ||
* Copyright 2017-2024 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 | ||
* | ||
* https://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.value; | ||
|
||
/** | ||
* The property catalog to use. | ||
* | ||
* @since 4.7.0 | ||
*/ | ||
public enum PropertyCatalog { | ||
/** | ||
* The catalog that contains the raw keys. | ||
*/ | ||
RAW, | ||
/** | ||
* The catalog that contains normalized keys. A key is normalized into | ||
* lower case hyphen separated form. For example an environment variable {@code FOO_BAR} would be | ||
* normalized to {@code foo.bar}. | ||
*/ | ||
NORMALIZED, | ||
/** | ||
* The catalog that contains normalized keys and also generated keys. A synthetic key can be generated from | ||
* an environment variable such as {@code FOO_BAR_BAZ} which will produce the following keys: {@code foo.bar.baz}, | ||
* {@code foo.bar-baz}, and {@code foo-bar.baz}. | ||
*/ | ||
GENERATED | ||
} |
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
44 changes: 44 additions & 0 deletions
44
...io/micronaut/inject/configproperties/eachbeanparameter/EachPropertyPropertiesDefault.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,44 @@ | ||
package io.micronaut.inject.configproperties.eachbeanparameter; | ||
|
||
import io.micronaut.context.annotation.ConfigurationInject; | ||
import io.micronaut.context.annotation.EachProperty; | ||
import io.micronaut.context.annotation.Parameter; | ||
import io.micronaut.context.annotation.Requires; | ||
|
||
@Requires(property = "spec", value = "DisabledNormalizationSpec") | ||
@EachProperty(value = "app.default") | ||
public class EachPropertyPropertiesDefault { | ||
|
||
private String name; | ||
private String url; | ||
private int serverPort; | ||
|
||
@ConfigurationInject | ||
public EachPropertyPropertiesDefault(@Parameter String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getServerPort() { | ||
return serverPort; | ||
} | ||
|
||
public void setServerPort(int serverPort) { | ||
this.serverPort = serverPort; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
.../micronaut/inject/configproperties/eachbeanparameter/EachPropertyPropertiesGenerated.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,45 @@ | ||
package io.micronaut.inject.configproperties.eachbeanparameter; | ||
|
||
import io.micronaut.context.annotation.ConfigurationInject; | ||
import io.micronaut.context.annotation.EachProperty; | ||
import io.micronaut.context.annotation.Parameter; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.core.value.PropertyCatalog; | ||
|
||
@Requires(property = "spec", value = "DisabledNormalizationSpec") | ||
@EachProperty(value = "app.generated", catalog = PropertyCatalog.GENERATED) | ||
public class EachPropertyPropertiesGenerated { | ||
|
||
private String name; | ||
private String url; | ||
private int serverPort; | ||
|
||
@ConfigurationInject | ||
public EachPropertyPropertiesGenerated(@Parameter String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getServerPort() { | ||
return serverPort; | ||
} | ||
|
||
public void setServerPort(int serverPort) { | ||
this.serverPort = serverPort; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...micronaut/inject/configproperties/eachbeanparameter/EachPropertyPropertiesNormalized.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,45 @@ | ||
package io.micronaut.inject.configproperties.eachbeanparameter; | ||
|
||
import io.micronaut.context.annotation.ConfigurationInject; | ||
import io.micronaut.context.annotation.EachProperty; | ||
import io.micronaut.context.annotation.Parameter; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.core.value.PropertyCatalog; | ||
|
||
@Requires(property = "spec", value = "DisabledNormalizationSpec") | ||
@EachProperty(value = "app.normalized", catalog = PropertyCatalog.NORMALIZED) | ||
public class EachPropertyPropertiesNormalized { | ||
|
||
private String name; | ||
private String url; | ||
private int serverPort; | ||
|
||
@ConfigurationInject | ||
public EachPropertyPropertiesNormalized(@Parameter String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getServerPort() { | ||
return serverPort; | ||
} | ||
|
||
public void setServerPort(int serverPort) { | ||
this.serverPort = serverPort; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ovy/io/micronaut/inject/configproperties/eachbeanparameter/EachPropertyPropertiesRaw.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,45 @@ | ||
package io.micronaut.inject.configproperties.eachbeanparameter; | ||
|
||
import io.micronaut.context.annotation.ConfigurationInject; | ||
import io.micronaut.context.annotation.EachProperty; | ||
import io.micronaut.context.annotation.Parameter; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.core.value.PropertyCatalog; | ||
|
||
@Requires(property = "spec", value = "DisabledNormalizationSpec") | ||
@EachProperty(value = "app.raw", catalog = PropertyCatalog.RAW) | ||
public class EachPropertyPropertiesRaw { | ||
|
||
private String name; | ||
private String url; | ||
private int serverPort; | ||
|
||
@ConfigurationInject | ||
public EachPropertyPropertiesRaw(@Parameter String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getServerPort() { | ||
return serverPort; | ||
} | ||
|
||
public void setServerPort(int serverPort) { | ||
this.serverPort = serverPort; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
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
Oops, something went wrong.