This is an automated email from the ASF dual-hosted git repository.
anatole pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tamaya-sandbox.git
The following commit(s) were added to refs/heads/master by this push:
new e212349 Fixed quality/checkstyle issues.
e212349 is described below
commit e212349b720a97b4add9afbc321a9be7ae4ab6ab
Author: Anatole Tresch <[email protected]>
AuthorDate: Sun Feb 24 21:10:28 2019 +0100
Fixed quality/checkstyle issues.
---
.../apache/tamaya/jsr382/JavaConfigAdapter.java | 24 ++++----
.../tamaya/jsr382/JavaConfigAdapterFactory.java | 66 +++++++++++++---------
.../tamaya/jsr382/JavaConfigBuilderAdapter.java | 22 +++++---
.../tamaya/jsr382/JavaConfigConverterAdapter.java | 7 ++-
.../org/apache/tamaya/jsr382/JavaConfigSource.java | 16 +++---
.../tamaya/jsr382/JavaConfigSourceProvider.java | 16 +++---
.../jsr382/PrioritizedPropertyConverter.java | 5 +-
.../apache/tamaya/jsr382/TamayaConfigAccessor.java | 39 +++++++------
.../jsr382/TamayaConfigProviderResolver.java | 8 +--
.../apache/tamaya/jsr382/TamayaConfigSnapshot.java | 10 ++--
.../tamaya/jsr382/TamayaConfigurationAdapter.java | 14 +++--
.../jsr382/TamayaPropertyConverterAdapter.java | 7 ++-
.../tamaya/jsr382/TamayaPropertySourceAdapter.java | 10 ++--
.../TamayaPropertySourceProviderAdapter.java | 14 +++--
.../apache/tamaya/jsr382/cdi/ConfiguredField.java | 8 +--
.../apache/tamaya/jsr382/cdi/ConfiguredMethod.java | 6 +-
.../apache/tamaya/jsr382/cdi/ConfiguredType.java | 9 +--
.../tamaya/jsr382/cdi/JavaConfigCDIExtension.java | 23 ++++----
.../cdi/JavaConfigConfigurationProducer.java | 36 ++++++------
.../converter/BooleanAsIntegerConverterFix.java | 10 ++--
.../tamaya/jsr382/converter/ProviderConverter.java | 23 ++++----
21 files changed, 206 insertions(+), 167 deletions(-)
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapter.java
index 9791f1f..cf337a9 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapter.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapter.java
@@ -40,17 +40,19 @@ public class JavaConfigAdapter implements Config,
Serializable {
/**
* Creates a new JSR configuration instance based on the given Tamaya
configuration.
+ *
* @param delegate the configuration, not null.s
*/
- public JavaConfigAdapter(Configuration delegate){
+ public JavaConfigAdapter(Configuration delegate) {
this.delegate = Objects.requireNonNull(delegate);
}
/**
* Access the current configuration delegate.
+ *
* @return the Tamaya configuration delegate, never null.
*/
- public Configuration getConfiguration(){
+ public Configuration getConfiguration() {
return this.delegate;
}
@@ -58,14 +60,14 @@ public class JavaConfigAdapter implements Config,
Serializable {
@Override
public <T> T getValue(String propertyName, Class<T> propertyType) {
T value = null;
- try{
+ try {
value = delegate.get(propertyName, propertyType);
- }catch(ConfigException e){
- if(e.toString().contains("Unparseable")){
+ } catch (ConfigException e) {
+ if (e.toString().contains("Unparseable")) {
throw new IllegalArgumentException("Invalid type: " +
propertyType.getName());
}
}
- if(value == null){
+ if (value == null) {
throw new NoSuchElementException("No such config property: " +
propertyName);
}
return value;
@@ -96,16 +98,16 @@ public class JavaConfigAdapter implements Config,
Serializable {
return
JavaConfigAdapterFactory.toConfigSources(delegate.getContext().getPropertySources());
}
- private void writeObject(ObjectOutputStream out) throws IOException{
- if(!(this.delegate instanceof Serializable)){
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ if (!(this.delegate instanceof Serializable)) {
out.writeObject(this.delegate.getSnapshot());
- }else {
+ } else {
out.writeObject(this.delegate);
}
}
- private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException{
- this.delegate = (Configuration)in.readObject();
+ private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
+ this.delegate = (Configuration) in.readObject();
}
@Override
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapterFactory.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapterFactory.java
index 62dd402..fd5216f 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapterFactory.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigAdapterFactory.java
@@ -50,34 +50,38 @@ public final class JavaConfigAdapterFactory {
/**
* Singleton constructor.
*/
- private JavaConfigAdapterFactory(){}
+ private JavaConfigAdapterFactory() {
+ }
/**
* Converts a Tamaya {@link Configuration} into a JavaConfig.io {@link
javax.config.Config}.
+ *
* @param config the Tamaya {@link Configuration} instance, not null.
* @return the corresponding JavaConfig.io {@link Config} instance, never
null.
*/
- public static Config toConfig(Configuration config){
- if(config instanceof TamayaConfigurationAdapter){
- return ((TamayaConfigurationAdapter)config).getConfig();
+ public static Config toConfig(Configuration config) {
+ if (config instanceof TamayaConfigurationAdapter) {
+ return ((TamayaConfigurationAdapter) config).getConfig();
}
return new JavaConfigAdapter(config);
}
/**
* Converts a JavaConfig {@link Config}s into Tamaya {@link
Configuration}s.
+ *
* @param config the JavaConfig {@link Config} instance, not null.
* @return the corresponding Tamaya {@link Configuration} instance, never
null.
*/
- public static Configuration toConfiguration(Config config){
- if(config instanceof JavaConfigAdapter){
- return ((JavaConfigAdapter)config).getConfiguration();
+ public static Configuration toConfiguration(Config config) {
+ if (config instanceof JavaConfigAdapter) {
+ return ((JavaConfigAdapter) config).getConfiguration();
}
return new TamayaConfigurationAdapter(config);
}
/**
* Converts a JavaConfig {@link Config}s into Tamaya {@link
ConfigurationContext}s.
+ *
* @param config the JavaConfig {@link Config} instance, not null.
* @return the corresponding Tamaya {@link ConfigurationContext} instance,
never null.
*/
@@ -88,7 +92,7 @@ public final class JavaConfigAdapterFactory {
sources.add(toPropertySource(cs));
}
Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = new
HashMap<>();
- for (PropertyConverter<?> conv :
serviceContext.getServices(PropertyConverter.class)){
+ for (PropertyConverter<?> conv :
serviceContext.getServices(PropertyConverter.class)) {
converters.computeIfAbsent(TypeLiteral.of(
TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(),
PropertyConverter.class)[0]),
(k) -> new ArrayList<>()).add(conv);
@@ -104,12 +108,13 @@ public final class JavaConfigAdapterFactory {
/**
* Converts a Tamaya {@link PropertySource}s into a JavaConfig.io {@link
ConfigSource}.
+ *
* @param propertySources the Tamaya {@link PropertySource} instances, not
null.
* @return the corresponding JavaConfig.io {@link ConfigSource} instance,
never null.
*/
public static List<ConfigSource> toConfigSources(Iterable<PropertySource>
propertySources) {
List<ConfigSource> configSources = new ArrayList<>();
- for(PropertySource ps:propertySources){
+ for (PropertySource ps : propertySources) {
configSources.add(toConfigSource(ps));
}
Collections.reverse(configSources);
@@ -118,12 +123,13 @@ public final class JavaConfigAdapterFactory {
/**
* Converts a JavaConfig {@link ConfigSource}s into Tamaya {@link
PropertySource}s.
+ *
* @param configSources the JavaConfig {@link ConfigSource} instances, not
null.
* @return the corresponding Tamaya {@link PropertySource} instances,
never null.
*/
public static List<PropertySource>
toPropertySources(Iterable<ConfigSource> configSources) {
List<PropertySource> propertySources = new ArrayList<>();
- for(ConfigSource cs:configSources){
+ for (ConfigSource cs : configSources) {
propertySources.add(toPropertySource(cs));
}
return propertySources;
@@ -131,38 +137,41 @@ public final class JavaConfigAdapterFactory {
/**
* Converts a Tamaya {@link PropertySource} into a JavaConfig.io {@link
ConfigSource}.
+ *
* @param propertySource the Tamaya {@link PropertySource} instance, not
null.
* @return the corresponding JavaConfig.io {@link ConfigSource} instance,
never null.
*/
public static ConfigSource toConfigSource(PropertySource propertySource) {
- if(propertySource instanceof TamayaPropertySourceAdapter){
- return
((TamayaPropertySourceAdapter)propertySource).getConfigSource();
+ if (propertySource instanceof TamayaPropertySourceAdapter) {
+ return ((TamayaPropertySourceAdapter)
propertySource).getConfigSource();
}
return new JavaConfigSource(propertySource);
}
/**
* Converts a JavaConfig {@link ConfigSource} into a Tamaya {@link
PropertySource}.
+ *
* @param configSource the JavaConfig {@link ConfigSource} instance, not
null.
* @return the corresponding Tamaya {@link PropertySource} instance, never
null.
*/
public static PropertySource toPropertySource(ConfigSource configSource) {
- if(configSource instanceof JavaConfigSource){
- return ((JavaConfigSource)configSource).getPropertySource();
+ if (configSource instanceof JavaConfigSource) {
+ return ((JavaConfigSource) configSource).getPropertySource();
}
return new TamayaPropertySourceAdapter(configSource);
}
/**
* Converts a JavaConfig {@link Converter} into a Tamaya {@link
PropertyConverter}.
+ *
* @param converter the JavaConfig {@link Converter} instance, not null.
- * @param <T> the target type
- * @param priority the priority level of this converter.
+ * @param <T> the target type
+ * @param priority the priority level of this converter.
* @return the corresponding Tamaya {@link PropertyConverter} instance,
never null.
*/
public static <T> PropertyConverter<T> toPropertyConverter(Converter<T>
converter, int priority) {
- if(converter instanceof JavaConfigConverterAdapter){
- return
PrioritizedPropertyConverter.of(((JavaConfigConverterAdapter)converter).getPropertyConverter(),
priority);
+ if (converter instanceof JavaConfigConverterAdapter) {
+ return
PrioritizedPropertyConverter.of(((JavaConfigConverterAdapter)
converter).getPropertyConverter(), priority);
}
return new TamayaPropertyConverterAdapter(converter);
}
@@ -170,8 +179,9 @@ public final class JavaConfigAdapterFactory {
/**
* Converts a JavaConfig {@link Converter} into a Tamaya {@link
PropertyConverter} using default priority of
* {@code 100}.
+ *
* @param converter the JavaConfig {@link Converter} instance, not null.
- * @param <T> the target type
+ * @param <T> the target type
* @return the corresponding Tamaya {@link PropertyConverter} instance,
never null.
*/
public static <T> PropertyConverter<T> toPropertyConverter(Converter<T>
converter) {
@@ -180,19 +190,21 @@ public final class JavaConfigAdapterFactory {
/**
* Converts a Tamaya {@link PropertyConverter} into a JavaConfig.io {@link
Converter}.
+ *
* @param converter the Tamaya {@link PropertyConverter} instance, not
null.
- * @param <T> the target type
+ * @param <T> the target type
* @return the corresponding JavaConfig.io {@link Converter} instance,
never null.
*/
public static <T> Converter<T> toConverter(PropertyConverter<T> converter)
{
- if(converter instanceof TamayaPropertyConverterAdapter){
- return ((TamayaPropertyConverterAdapter)converter).getConverter();
+ if (converter instanceof TamayaPropertyConverterAdapter) {
+ return ((TamayaPropertyConverterAdapter) converter).getConverter();
}
return new JavaConfigConverterAdapter(converter);
}
/**
* Converts a Tamaya {@link ConfigurationBuilder} into a JavaConfig.io
{@link ConfigBuilder}.
+ *
* @param builder the Tamaya {@link ConfigurationBuilder} instance, not
null.
* @return the corresponding JavaConfig.io {@link ConfigBuilder} instance,
never null.
*/
@@ -203,13 +215,14 @@ public final class JavaConfigAdapterFactory {
/**
* Converts the given Tamaya key, value map into a corresponding String
based map, hereby
* omitting all meta-entries.
+ *
* @param properties the Tamaya key, value map, not null.
* @return the corresponding String based map, never null.
*/
public static Map<String, String> toStringMap(Map<String, PropertyValue>
properties) {
Map<String, String> valueMap = new HashMap<>(properties.size());
- for(Map.Entry<String,PropertyValue> en:properties.entrySet()){
- if(en.getValue().getValue()!=null) {
+ for (Map.Entry<String, PropertyValue> en : properties.entrySet()) {
+ if (en.getValue().getValue() != null) {
valueMap.put(en.getKey(), en.getValue().getValue());
}
}
@@ -219,13 +232,14 @@ public final class JavaConfigAdapterFactory {
/**
* Converts the given String based key, value map into a corresponding
String,PropertyValue
* based map.
+ *
* @param properties the String based key, value map, not null.
- * @param source the source of the entries, not null.
+ * @param source the source of the entries, not null.
* @return the corresponding String,PropertyValue based map, never null.
*/
public static Map<String, PropertyValue> toPropertyValueMap(Map<String,
String> properties, String source) {
Map<String, PropertyValue> valueMap = new HashMap<>(properties.size());
- for(Map.Entry<String,String> en:properties.entrySet()){
+ for (Map.Entry<String, String> en : properties.entrySet()) {
valueMap.put(en.getKey(), PropertyValue.of(en.getKey(),
en.getValue(), source));
}
return valueMap;
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigBuilderAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigBuilderAdapter.java
index 951901f..c26de17 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigBuilderAdapter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigBuilderAdapter.java
@@ -35,24 +35,26 @@ import java.util.Objects;
/**
* Created by atsticks on 23.03.17.
*/
-final class JavaConfigBuilderAdapter implements ConfigBuilder{
+final class JavaConfigBuilderAdapter implements ConfigBuilder {
private ConfigurationBuilder configBuilder;
/**
* Create a new ConfigBuilder using the given Tamaya config builder.
+ *
* @param configBuilder
*/
- JavaConfigBuilderAdapter(ConfigurationBuilder configBuilder){
+ JavaConfigBuilderAdapter(ConfigurationBuilder configBuilder) {
this.configBuilder = Objects.requireNonNull(configBuilder);
configBuilder.addDefaultPropertyConverters();
}
/**
* Access the underlying Tamaya {@link ConfigurationBuilder}.
+ *
* @return the Tamaya builder, not null.
*/
- public ConfigurationBuilder getConfigurationBuilder(){
+ public ConfigurationBuilder getConfigurationBuilder() {
return configBuilder;
}
@@ -79,14 +81,15 @@ final class JavaConfigBuilderAdapter implements
ConfigBuilder{
/**
* Add ConfigSources registered using the ServiceLoader.
+ *
* @return the ConfigBuilder with the added config sources
*/
@Override
public ConfigBuilder addDiscoveredSources() {
- for(ConfigSource configSource:
ServiceContextManager.getServiceContext().getServices(ConfigSource.class)){
+ for (ConfigSource configSource :
ServiceContextManager.getServiceContext().getServices(ConfigSource.class)) {
configBuilder.addPropertySources(JavaConfigAdapterFactory.toPropertySource(configSource));
}
- for(ConfigSourceProvider configSourceProvider:
ServiceContextManager.getServiceContext().getServices(ConfigSourceProvider.class)){
+ for (ConfigSourceProvider configSourceProvider :
ServiceContextManager.getServiceContext().getServices(ConfigSourceProvider.class))
{
configBuilder.addPropertySources(JavaConfigAdapterFactory.toPropertySources(configSourceProvider.getConfigSources(
Thread.currentThread().getContextClassLoader()
)));
@@ -97,13 +100,14 @@ final class JavaConfigBuilderAdapter implements
ConfigBuilder{
/**
* Add Converters registered using the ServiceLoader.
+ *
* @return the ConfigBuilder with the added config converters
*/
@Override
public ConfigBuilder addDiscoveredConverters() {
- for(Converter<?> converter:
ServiceContextManager.getServiceContext().getServices(Converter.class)){
+ for (Converter<?> converter :
ServiceContextManager.getServiceContext().getServices(Converter.class)) {
TypeLiteral targetType = TypeLiteral.of(
-
TypeLiteral.getGenericInterfaceTypeParameters(converter.getClass(),Converter.class)[0]);
+
TypeLiteral.getGenericInterfaceTypeParameters(converter.getClass(),
Converter.class)[0]);
configBuilder.addPropertyConverters(targetType,
JavaConfigAdapterFactory.toPropertyConverter(converter));
}
@@ -118,7 +122,7 @@ final class JavaConfigBuilderAdapter implements
ConfigBuilder{
@Override
public ConfigBuilder withSources(ConfigSource... sources) {
- for(ConfigSource source:sources){
+ for (ConfigSource source : sources) {
configBuilder.addPropertySources(JavaConfigAdapterFactory.toPropertySource(source));
}
return this;
@@ -137,7 +141,7 @@ final class JavaConfigBuilderAdapter implements
ConfigBuilder{
@Override
public ConfigBuilder withConverters(Converter<?>... converters) {
- for(Converter<?> converter:converters){
+ for (Converter<?> converter : converters) {
TypeLiteral lit = TypeLiteral.of(converter.getClass());
TypeLiteral target = TypeLiteral.of(lit.getType());
configBuilder.removePropertyConverters(target);
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigConverterAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigConverterAdapter.java
index 924ebaf..d50a806 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigConverterAdapter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigConverterAdapter.java
@@ -28,6 +28,7 @@ import java.util.Objects;
/**
* Tamaya converter implementation that wraps a Java config {@link
javax.config.spi.Converter} instance.
+ *
* @param <T> the converter type
*/
public class JavaConfigConverterAdapter<T> implements Converter<T> {
@@ -36,17 +37,19 @@ public class JavaConfigConverterAdapter<T> implements
Converter<T> {
/**
* Creates a new Converter, baed on the given Tamaya {@link
org.apache.tamaya.spi.PropertyConverter}.
+ *
* @param delegate the delegate, not null.
*/
- public JavaConfigConverterAdapter(PropertyConverter<T> delegate){
+ public JavaConfigConverterAdapter(PropertyConverter<T> delegate) {
this.delegate = Objects.requireNonNull(delegate);
}
/**
* Access the underlying Tamaya converter.
+ *
* @return the Tamaya converter, not null.
*/
- public PropertyConverter<T> getPropertyConverter(){
+ public PropertyConverter<T> getPropertyConverter() {
return this.delegate;
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSource.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSource.java
index 5af6f78..663d369 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSource.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSource.java
@@ -31,15 +31,15 @@ import java.util.function.Consumer;
/**
* Javaconfig {@link ConfigSource} implementation that wraps a {@link
PropertySource} instance.
*/
-public class JavaConfigSource implements ConfigSource{
+public class JavaConfigSource implements ConfigSource {
private PropertySource delegate;
- public JavaConfigSource(PropertySource propertySource){
+ public JavaConfigSource(PropertySource propertySource) {
this.delegate = Objects.requireNonNull(propertySource);
}
- public PropertySource getPropertySource(){
+ public PropertySource getPropertySource() {
return this.delegate;
}
@@ -56,7 +56,7 @@ public class JavaConfigSource implements ConfigSource{
@Override
public String getValue(String key) {
PropertyValue value = delegate.get(key);
- if(value!=null){
+ if (value != null) {
return value.getValue();
}
return null;
@@ -69,8 +69,8 @@ public class JavaConfigSource implements ConfigSource{
private Map<String, String> toMap(Map<String, PropertyValue> properties) {
Map<String, String> valueMap = new HashMap<>(properties.size());
- for(Map.Entry<String,PropertyValue> en:properties.entrySet()){
- if(en.getValue().getValue()!=null) {
+ for (Map.Entry<String, PropertyValue> en : properties.entrySet()) {
+ if (en.getValue().getValue() != null) {
valueMap.put(en.getKey(), en.getValue().getValue());
}
}
@@ -88,9 +88,9 @@ public class JavaConfigSource implements ConfigSource{
*/
// TODO implement change support in Tamaya
public ChangeSupport setOnAttributeChange(Consumer<Set<String>> callback) {
- switch(delegate.getChangeSupport()){
+ switch (delegate.getChangeSupport()) {
case SUPPORTED:
- delegate.addChangeListener((s,ps) -> {
+ delegate.addChangeListener((s, ps) -> {
callback.accept(s);
});
return ChangeSupport.SUPPORTED;
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSourceProvider.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSourceProvider.java
index 1efd4ba..b3e2795 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSourceProvider.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/JavaConfigSourceProvider.java
@@ -29,23 +29,23 @@ import java.util.*;
/**
* JavaConfig {@link javax.config.spi.ConfigSource} implementation that wraps
a {@link PropertySource} instance.
*/
-public class JavaConfigSourceProvider implements ConfigSourceProvider{
+public class JavaConfigSourceProvider implements ConfigSourceProvider {
private PropertySourceProvider delegate;
- public JavaConfigSourceProvider(PropertySourceProvider
propertySourceProvider){
+ public JavaConfigSourceProvider(PropertySourceProvider
propertySourceProvider) {
this.delegate = Objects.requireNonNull(propertySourceProvider);
}
- public PropertySourceProvider getPropertySourceProvider(){
+ public PropertySourceProvider getPropertySourceProvider() {
return this.delegate;
}
private Map<String, String> toMap(Map<String, PropertyValue> properties) {
Map<String, String> valueMap = new HashMap<>(properties.size());
- for(Map.Entry<String,PropertyValue> en:properties.entrySet()){
- if(en.getValue().getValue()!=null) {
+ for (Map.Entry<String, PropertyValue> en : properties.entrySet()) {
+ if (en.getValue().getValue() != null) {
valueMap.put(en.getKey(), en.getValue().getValue());
}
}
@@ -54,10 +54,10 @@ public class JavaConfigSourceProvider implements
ConfigSourceProvider{
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader)
{
- if(delegate instanceof TamayaPropertySourceProviderAdapter){
- return
((TamayaPropertySourceProviderAdapter)delegate).getConfigSourceProvider()
+ if (delegate instanceof TamayaPropertySourceProviderAdapter) {
+ return ((TamayaPropertySourceProviderAdapter)
delegate).getConfigSourceProvider()
.getConfigSources(forClassLoader);
- }else {
+ } else {
return
JavaConfigAdapterFactory.toConfigSources(delegate.getPropertySources());
}
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/PrioritizedPropertyConverter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/PrioritizedPropertyConverter.java
index 9d33d61..561849d 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/PrioritizedPropertyConverter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/PrioritizedPropertyConverter.java
@@ -25,6 +25,7 @@ import java.util.Objects;
/**
* A prioritized property converter.
+ *
* @param <T> the property type
*/
final class PrioritizedPropertyConverter<T> implements PropertyConverter<T> {
@@ -38,8 +39,8 @@ final class PrioritizedPropertyConverter<T> implements
PropertyConverter<T> {
}
public static <T> PropertyConverter<T> of(PropertyConverter<T>
propertyConverter, int priority) {
- if(propertyConverter instanceof PrioritizedPropertyConverter){
- return
((PrioritizedPropertyConverter)propertyConverter).setPriority(priority);
+ if (propertyConverter instanceof PrioritizedPropertyConverter) {
+ return ((PrioritizedPropertyConverter)
propertyConverter).setPriority(priority);
}
return new PrioritizedPropertyConverter<>(propertyConverter, priority);
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigAccessor.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigAccessor.java
index d243ece..d80e7ae 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigAccessor.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigAccessor.java
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
/**
* Tamaya implementation type for the {@link ConfigAccessor} type.
+ *
* @param <T> the target type.
*/
class TamayaConfigAccessor<T> implements ConfigAccessor<T> {
@@ -48,6 +49,7 @@ class TamayaConfigAccessor<T> implements ConfigAccessor<T> {
/**
* Constructor.
+ *
* @param javaConfigAdapter
* @param name
*/
@@ -70,17 +72,18 @@ class TamayaConfigAccessor<T> implements ConfigAccessor<T> {
/**
* Access the list of al current possible candidate keys to evaluate a
value for the given accessor.
+ *
* @return the list of al current possible candidate keys, not null.
*/
public List<String> getCandidateKeys() {
List<String> keys = new ArrayList<>();
List<List<String>> listList = new ArrayList<>();
List<String> maxList = new ArrayList<>(lookupSuffixes);
- while(!maxList.isEmpty()){
+ while (!maxList.isEmpty()) {
listList.add(new ArrayList(maxList));
maxList.remove(0);
}
- for(List<String> list:listList) {
+ for (List<String> list : listList) {
keys.addAll(getSuffixKeys(list));
}
keys.add(getPropertyName());
@@ -89,11 +92,11 @@ class TamayaConfigAccessor<T> implements ConfigAccessor<T> {
private List<String> getSuffixKeys(List<String> list) {
List<String> result = new ArrayList<>();
- while(!list.isEmpty()){
- result.add(getPropertyName()+'.'+ String.join(".", list));
- if(list.size()>1) {
+ while (!list.isEmpty()) {
+ result.add(getPropertyName() + '.' + String.join(".", list));
+ if (list.size() > 1) {
list.remove(list.size() - 2);
- }else{
+ } else {
list.remove(0);
}
}
@@ -162,14 +165,14 @@ class TamayaConfigAccessor<T> implements
ConfigAccessor<T> {
@Override
public T getValue() {
- if(this.timeout > System.currentTimeMillis()){
+ if (this.timeout > System.currentTimeMillis()) {
return this.cachedValue;
}
T value = getValueInternal(name);
- if(value==null){
+ if (value == null) {
value = getValueInternalFromDefaults();
}
- if(value==null){
+ if (value == null) {
throw new IllegalArgumentException("No such value: " + name);
}
return value;
@@ -177,15 +180,15 @@ class TamayaConfigAccessor<T> implements
ConfigAccessor<T> {
private T getValueInternal(String key) {
T value = null;
- if(customConverter!=null){
+ if (customConverter != null) {
String textVal =
javaConfigAdapter.getConfiguration().getOrDefault(name, String.class, null);
- if(textVal==null){
+ if (textVal == null) {
textVal = stringDefaultValue;
}
- if(textVal!=null) {
+ if (textVal != null) {
value = customConverter.convert(textVal);
}
- }else {
+ } else {
value = javaConfigAdapter.getConfiguration().getOrDefault(name,
targetType, null);
}
return value;
@@ -193,14 +196,14 @@ class TamayaConfigAccessor<T> implements
ConfigAccessor<T> {
private T getValueInternalFromDefaults() {
T value = null;
- if(customConverter!=null){
+ if (customConverter != null) {
String textVal = stringDefaultValue;
- if(textVal!=null) {
+ if (textVal != null) {
value = customConverter.convert(textVal);
}
}
// Should we also try to convert with the String default value and
existing converters?
- if(value==null){
+ if (value == null) {
value = typedDefaultValue;
}
return value;
@@ -208,13 +211,13 @@ class TamayaConfigAccessor<T> implements
ConfigAccessor<T> {
@Override
public T getValue(ConfigSnapshot configSnapshot) {
- return ((TamayaConfigSnapshot)configSnapshot).getConfiguration()
+ return ((TamayaConfigSnapshot) configSnapshot).getConfiguration()
.get(name, targetType);
}
@Override
public Optional<T> getOptionalValue(ConfigSnapshot configSnapshot) {
- return
Optional.ofNullable(((TamayaConfigSnapshot)configSnapshot).getConfiguration()
+ return Optional.ofNullable(((TamayaConfigSnapshot)
configSnapshot).getConfiguration()
.getOrDefault(name, targetType, null));
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigProviderResolver.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigProviderResolver.java
index 8c4af47..167b349 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigProviderResolver.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigProviderResolver.java
@@ -43,7 +43,7 @@ public class TamayaConfigProviderResolver extends
ConfigProviderResolver {
@Override
public Config getConfig(ClassLoader loader) {
Config config = this.configs.get(loader);
- if(config==null){
+ if (config == null) {
ConfigurationBuilder builder =
Configuration.createConfigurationBuilder();
builder.setClassLoader(loader);
builder.addDefaultPropertyConverters();
@@ -63,7 +63,7 @@ public class TamayaConfigProviderResolver extends
ConfigProviderResolver {
@Override
public void registerConfig(Config config, ClassLoader classLoader) {
- if(configs.containsKey(classLoader)){
+ if (configs.containsKey(classLoader)) {
Logger.getLogger(getClass().getName())
.warning("Replacing existing config for classloader: " +
classLoader);
// throw new IllegalArgumentException("Already a config registered
with classloader: " + classLoader);
@@ -73,8 +73,8 @@ public class TamayaConfigProviderResolver extends
ConfigProviderResolver {
@Override
public void releaseConfig(Config config) {
- for(Map.Entry<ClassLoader, Config> en: this.configs.entrySet()){
- if(en.getValue().equals(config)){
+ for (Map.Entry<ClassLoader, Config> en : this.configs.entrySet()) {
+ if (en.getValue().equals(config)) {
this.configs.remove(en.getKey());
return;
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigSnapshot.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigSnapshot.java
index a148cf2..3ec228b 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigSnapshot.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigSnapshot.java
@@ -31,20 +31,20 @@ import java.util.Set;
/**
* Implementation of a {@link ConfigSnapshot} based on Tamaya resources.
*/
-class TamayaConfigSnapshot implements ConfigSnapshot {
+class TamayaConfigSnapshot implements ConfigSnapshot {
private DefaultConfigurationSnapshot snapshot;
private List<ConfigAccessor<?>> accessors = new ArrayList<>();
- public TamayaConfigSnapshot(Configuration config, ConfigAccessor<?>...
configAccessors){
+ public TamayaConfigSnapshot(Configuration config, ConfigAccessor<?>...
configAccessors) {
Set<String> keys = new HashSet<>();
- for(ConfigAccessor<?> accessor:configAccessors){
- keys.addAll(((TamayaConfigAccessor)accessor).getCandidateKeys());
+ for (ConfigAccessor<?> accessor : configAccessors) {
+ keys.addAll(((TamayaConfigAccessor) accessor).getCandidateKeys());
}
this.snapshot = new DefaultConfigurationSnapshot(config, keys);
}
- public Configuration getConfiguration(){
+ public Configuration getConfiguration() {
return snapshot;
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigurationAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigurationAdapter.java
index bdc19e8..1808138 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigurationAdapter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaConfigurationAdapter.java
@@ -30,25 +30,27 @@ import java.util.*;
/**
* Configuration implementation that wraps a Javaconfig {@link Config}
instance.
*/
-class TamayaConfigurationAdapter implements Configuration{
+class TamayaConfigurationAdapter implements Configuration {
private Config delegate;
private ConfigurationContext context;
/**
* Creates a new adapter based on the given {@link Config}.
+ *
* @param config the config, not null.
*/
- public TamayaConfigurationAdapter(Config config){
+ public TamayaConfigurationAdapter(Config config) {
this.delegate = Objects.requireNonNull(config);
this.context = JavaConfigAdapterFactory.toConfigurationContext(config);
}
/**
* Get the underlying config.
+ *
* @return the underlying config, not null.
*/
- public Config getConfig(){
+ public Config getConfig() {
return delegate;
}
@@ -86,15 +88,15 @@ class TamayaConfigurationAdapter implements Configuration{
@Override
public Map<String, String> getProperties() {
- Map<String,String> properties = new HashMap<>();
- for(String key:this.delegate.getPropertyNames()) {
+ Map<String, String> properties = new HashMap<>();
+ for (String key : this.delegate.getPropertyNames()) {
properties.put(key, delegate.getValue(key, String.class));
}
return properties;
}
@Override
- public ConfigurationSnapshot getSnapshot(Iterable<String> keys){
+ public ConfigurationSnapshot getSnapshot(Iterable<String> keys) {
return new DefaultConfigurationSnapshot(this, keys);
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertyConverterAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertyConverterAdapter.java
index 7e64aca..e86fcf2 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertyConverterAdapter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertyConverterAdapter.java
@@ -27,6 +27,7 @@ import java.util.Objects;
/**
* Converter implementation that wraps a Javaconfig {@link Converter} instance.
+ *
* @param <T> the property converter type
*/
final class TamayaPropertyConverterAdapter<T> implements PropertyConverter<T> {
@@ -35,17 +36,19 @@ final class TamayaPropertyConverterAdapter<T> implements
PropertyConverter<T> {
/**
* Creates a new adapter instance.
+ *
* @param delegate the delegate, not null.
*/
- public TamayaPropertyConverterAdapter(Converter<T> delegate){
+ public TamayaPropertyConverterAdapter(Converter<T> delegate) {
this.delegate = Objects.requireNonNull(delegate);
}
/**
* Access the underlying converter instance.
+ *
* @return the underlying converter, not null.
*/
- public Converter<T> getConverter(){
+ public Converter<T> getConverter() {
return this.delegate;
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceAdapter.java
index 126d68d..b61a605 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceAdapter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceAdapter.java
@@ -36,17 +36,19 @@ class TamayaPropertySourceAdapter implements PropertySource
{
/**
* Creates a new instance.
+ *
* @param configSource the underlying config source, not null.
*/
- public TamayaPropertySourceAdapter(ConfigSource configSource){
+ public TamayaPropertySourceAdapter(ConfigSource configSource) {
this.delegate = Objects.requireNonNull(configSource);
}
/**
* Access the underlying config source.
+ *
* @return the underlying config source, not null.
*/
- public ConfigSource getConfigSource(){
+ public ConfigSource getConfigSource() {
return this.delegate;
}
@@ -63,7 +65,7 @@ class TamayaPropertySourceAdapter implements PropertySource {
@Override
public PropertyValue get(String key) {
- return PropertyValue.of(key, delegate.getValue(key),getName());
+ return PropertyValue.of(key, delegate.getValue(key), getName());
}
@Override
@@ -73,7 +75,7 @@ class TamayaPropertySourceAdapter implements PropertySource {
private Map<String, PropertyValue> toValueMap(Map<String, String>
properties) {
Map<String, PropertyValue> valueMap = new HashMap<>(properties.size());
- for(Map.Entry<String,String> en:properties.entrySet()){
+ for (Map.Entry<String, String> en : properties.entrySet()) {
valueMap.put(en.getKey(), PropertyValue.of(en.getKey(),
en.getValue(), getName()));
}
return valueMap;
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceProviderAdapter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceProviderAdapter.java
index 9040c48..b60bfbf 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceProviderAdapter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/TamayaPropertySourceProviderAdapter.java
@@ -28,33 +28,35 @@ import java.util.*;
/**
* Tamaya {@link PropertySourceProvider} implementation that wraps a {@link
ConfigSourceProvider} instance.
*/
-class TamayaPropertySourceProviderAdapter implements PropertySourceProvider{
+class TamayaPropertySourceProviderAdapter implements PropertySourceProvider {
private ConfigSourceProvider delegate;
/**
* Creates a new instance.
+ *
* @param configSourceProvider the provider, not null.
*/
- public TamayaPropertySourceProviderAdapter(ConfigSourceProvider
configSourceProvider){
+ public TamayaPropertySourceProviderAdapter(ConfigSourceProvider
configSourceProvider) {
this.delegate = Objects.requireNonNull(configSourceProvider);
}
/**
* Access the underlying provider.
+ *
* @return the provider, not null.
*/
- public ConfigSourceProvider getConfigSourceProvider(){
+ public ConfigSourceProvider getConfigSourceProvider() {
return this.delegate;
}
@Override
public Collection<PropertySource> getPropertySources() {
- if(delegate instanceof JavaConfigSourceProvider){
- return
((JavaConfigSourceProvider)delegate).getPropertySourceProvider()
+ if (delegate instanceof JavaConfigSourceProvider) {
+ return ((JavaConfigSourceProvider)
delegate).getPropertySourceProvider()
.getPropertySources();
- }else {
+ } else {
return JavaConfigAdapterFactory.toPropertySources(
delegate.getConfigSources(Thread.currentThread().getContextClassLoader()));
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredField.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredField.java
index cc06415..fbb7e82 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredField.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredField.java
@@ -29,8 +29,8 @@ public final class ConfiguredField {
private final Field field;
private String key;
- ConfiguredField(InjectionPoint injectionPoint, String key){
- this.field = (Field)injectionPoint.getMember();
+ ConfiguredField(InjectionPoint injectionPoint, String key) {
+ this.field = (Field) injectionPoint.getMember();
this.key = key;
}
@@ -51,7 +51,7 @@ public final class ConfiguredField {
}
public String getSignature() {
- return getName()+':'+field.getType().getName();
+ return getName() + ':' + field.getType().getName();
}
public void configure(Object instance, Configuration config) {
@@ -60,6 +60,6 @@ public final class ConfiguredField {
@Override
public String toString() {
- return "CDIConfiguredField["+getSignature()+']';
+ return "CDIConfiguredField[" + getSignature() + ']';
}
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredMethod.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredMethod.java
index d859d88..ac17d29 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredMethod.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredMethod.java
@@ -29,8 +29,8 @@ public final class ConfiguredMethod {
private final Method method;
private String key;
- ConfiguredMethod(InjectionPoint injectionPoint, String key){
- this.method = (Method)injectionPoint.getMember();
+ ConfiguredMethod(InjectionPoint injectionPoint, String key) {
+ this.method = (Method) injectionPoint.getMember();
this.key = key;
}
@@ -60,6 +60,6 @@ public final class ConfiguredMethod {
@Override
public String toString() {
- return "CDIConfiguredMethod["+getSignature()+']';
+ return "CDIConfiguredMethod[" + getSignature() + ']';
}
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredType.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredType.java
index 2730aaf..cc3864e 100644
--- a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredType.java
+++ b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/ConfiguredType.java
@@ -37,7 +37,7 @@ public final class ConfiguredType {
private final List<ConfiguredMethod> methods = new ArrayList<>();
private final List<ConfiguredField> fields = new ArrayList<>();
- public ConfiguredType(Class<?> type){
+ public ConfiguredType(Class<?> type) {
this.type = Objects.requireNonNull(type);
}
@@ -63,14 +63,15 @@ public final class ConfiguredType {
/**
* Used to build up during injection point processing.
+ *
* @param injectionPoint the CDI injection point, not null.
- * @param key the possible config key, not null.
+ * @param key the possible config key, not null.
*/
void addConfiguredMember(InjectionPoint injectionPoint, String key) {
Member member = injectionPoint.getMember();
- if(member instanceof Field){
+ if (member instanceof Field) {
this.fields.add(new ConfiguredField(injectionPoint, key));
- } else if(member instanceof Method){
+ } else if (member instanceof Method) {
this.methods.add(new ConfiguredMethod(injectionPoint, key));
}
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigCDIExtension.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigCDIExtension.java
index 12f93b3..3339fad 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigCDIExtension.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigCDIExtension.java
@@ -52,13 +52,14 @@ public class JavaConfigCDIExtension implements Extension {
/**
* Constructor for loading logging its load.
*/
- public JavaConfigCDIExtension(){
+ public JavaConfigCDIExtension() {
LOG.finest("Loading Tamaya JavaConfig Support...");
}
/**
* Method that checks the configuration injection points during deployment
for available configuration.
- * @param pb the bean to process.
+ *
+ * @param pb the bean to process.
* @param beanManager the bean manager to notify about new injections.
*/
public void retrieveTypes(@Observes final ProcessBean<?> pb, BeanManager
beanManager) {
@@ -71,17 +72,17 @@ public class JavaConfigCDIExtension implements Extension {
if
(injectionPoint.getAnnotated().isAnnotationPresent(ConfigProperty.class)) {
LOG.fine("Configuring: " + injectionPoint);
final ConfigProperty annotation =
injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
- String key =
!annotation.name().isEmpty()?annotation.name():JavaConfigConfigurationProducer.getDefaultKey(injectionPoint);
+ String key = !annotation.name().isEmpty() ? annotation.name()
: JavaConfigConfigurationProducer.getDefaultKey(injectionPoint);
configuredType.addConfiguredMember(injectionPoint, key);
Type originalType = injectionPoint.getType();
Type convertedType = unwrapType(originalType);
types.add(convertedType);
configured = true;
LOG.finest(() -> "Enabling Tamaya JavaConfig Configuration on
bean: " + configuredType.getName());
- }else if(injectionPoint.getMember() instanceof Method){
- Method method = (Method)injectionPoint.getMember();
- for(AnnotatedType paramType:
method.getAnnotatedParameterTypes()){
- if(paramType.isAnnotationPresent(ConfigProperty.class)) {
+ } else if (injectionPoint.getMember() instanceof Method) {
+ Method method = (Method) injectionPoint.getMember();
+ for (AnnotatedType paramType :
method.getAnnotatedParameterTypes()) {
+ if (paramType.isAnnotationPresent(ConfigProperty.class)) {
LOG.fine("Configuring method: " + injectionPoint);
final ConfigProperty annotation =
paramType.getAnnotation(ConfigProperty.class);
String key = !annotation.name().isEmpty() ?
annotation.name() :
JavaConfigConfigurationProducer.getDefaultKey(injectionPoint);
@@ -95,7 +96,7 @@ public class JavaConfigCDIExtension implements Extension {
}
}
}
- if(configured) {
+ if (configured) {
beanManager.fireEvent(configuredType);
}
}
@@ -108,15 +109,15 @@ public class JavaConfigCDIExtension implements Extension {
}
public void addConverter(@Observes final AfterBeanDiscovery abd, final
BeanManager bm) {
- if(!types.isEmpty() && convBean!=null) {
+ if (!types.isEmpty() && convBean != null) {
abd.addBean(new BridgingConfigBean(convBean, types));
}
}
private Type unwrapType(Type type) {
- if(type instanceof ParameterizedType) {
+ if (type instanceof ParameterizedType) {
Type rawType = ((ParameterizedType) type).getRawType();
- if(rawType == Provider.class || rawType == Instance.class) {
+ if (rawType == Provider.class || rawType == Instance.class) {
return ((ParameterizedType) type).getActualTypeArguments()[0];
}
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigConfigurationProducer.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigConfigurationProducer.java
index 8b462eb..a7ec82b 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigConfigurationProducer.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/cdi/JavaConfigConfigurationProducer.java
@@ -51,10 +51,10 @@ public class JavaConfigConfigurationProducer {
@Produces
@ConfigProperty
public Object resolveAndConvert(final InjectionPoint injectionPoint) {
- LOGGER.finest( () -> "Inject: " + injectionPoint);
+ LOGGER.finest(() -> "Inject: " + injectionPoint);
final ConfigProperty annotation =
injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
String key = annotation.name();
- if(key.isEmpty()){
+ if (key.isEmpty()) {
key = getDefaultKey(injectionPoint);
}
@@ -83,24 +83,24 @@ public class JavaConfigConfigurationProducer {
Configuration config = Configuration.current();
ConversionContext.Builder builder = new
ConversionContext.Builder(config,
key, TypeLiteral.of(targetType));
- if(targetType instanceof ParameterizedType){
- ParameterizedType pt = (ParameterizedType)targetType;
- if(pt.getRawType().equals(Provider.class)) {
+ if (targetType instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) targetType;
+ if (pt.getRawType().equals(Provider.class)) {
builder = new ConversionContext.Builder(config,
key, TypeLiteral.of(pt.getActualTypeArguments()[0]));
}
}
if (injectionPoint.getMember() instanceof AnnotatedElement) {
- AnnotatedElement annotated =
(AnnotatedElement)injectionPoint.getMember();
- if(annotated.isAnnotationPresent(ConfigProperty.class)) {
+ AnnotatedElement annotated = (AnnotatedElement)
injectionPoint.getMember();
+ if (annotated.isAnnotationPresent(ConfigProperty.class)) {
builder.setAnnotatedElement(annotated);
}
- }else if(injectionPoint.getMember() instanceof Method){
- Method method = (Method)injectionPoint.getMember();
- for(Type type:method.getParameterTypes()){
- if(type instanceof AnnotatedElement){
- AnnotatedElement annotated = (AnnotatedElement)type;
- if(annotated.isAnnotationPresent(ConfigProperty.class)) {
+ } else if (injectionPoint.getMember() instanceof Method) {
+ Method method = (Method) injectionPoint.getMember();
+ for (Type type : method.getParameterTypes()) {
+ if (type instanceof AnnotatedElement) {
+ AnnotatedElement annotated = (AnnotatedElement) type;
+ if (annotated.isAnnotationPresent(ConfigProperty.class)) {
builder.setAnnotatedElement(annotated);
}
}
@@ -112,14 +112,14 @@ public class JavaConfigConfigurationProducer {
static Object resolveValue(String defaultTextValue, ConversionContext
context, InjectionPoint injectionPoint) {
Config config = ConfigProviderResolver.instance().getConfig();
String textValue = config.getOptionalValue(context.getKey(),
String.class).orElse(defaultTextValue);
- if(String.class.equals(context.getTargetType().getRawType())){
+ if (String.class.equals(context.getTargetType().getRawType())) {
return textValue;
}
Object value = null;
if (textValue != null ||
Optional.class.equals(context.getTargetType().getRawType())) {
- LOGGER.log(Level.FINEST, () -> "Converting KEY: " +
context.getKey() + "("+context.getTargetType()+"), textValue: " + textValue);
+ LOGGER.log(Level.FINEST, () -> "Converting KEY: " +
context.getKey() + "(" + context.getTargetType() + "), textValue: " +
textValue);
List<PropertyConverter> converters =
Configuration.current().getContext()
-
.getPropertyConverters((TypeLiteral)context.getTargetType());
+ .getPropertyConverters((TypeLiteral)
context.getTargetType());
for (PropertyConverter<Object> converter : converters) {
try {
value = converter.convert(textValue, context);
@@ -138,12 +138,12 @@ public class JavaConfigConfigurationProducer {
}
@Produces
- public Config getConfiguration(){
+ public Config getConfiguration() {
return ConfigProvider.getConfig();
}
@Produces
- public ConfigBuilder getConfigBuilder(){
+ public ConfigBuilder getConfigBuilder() {
return ConfigProviderResolver.instance().getBuilder();
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/BooleanAsIntegerConverterFix.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/BooleanAsIntegerConverterFix.java
index c74871e..ec932aa 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/BooleanAsIntegerConverterFix.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/BooleanAsIntegerConverterFix.java
@@ -36,25 +36,25 @@ public class BooleanAsIntegerConverterFix implements
PropertyConverter<Boolean>
@Override
public Boolean convert(String value, ConversionContext context) {
context.addSupportedFormats(getClass(), "'1' (true), otherwise
false.");
- try{
+ try {
int val = Integer.parseInt(Objects.requireNonNull(value).trim());
- if(val==1) {
+ if (val == 1) {
return Boolean.TRUE;
}
return Boolean.FALSE;
- }catch(Exception e){
+ } catch (Exception e) {
// OK
return Boolean.FALSE;
}
}
@Override
- public boolean equals(Object o){
+ public boolean equals(Object o) {
return getClass().equals(o.getClass());
}
@Override
- public int hashCode(){
+ public int hashCode() {
return getClass().hashCode();
}
}
diff --git
a/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/ProviderConverter.java
b/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/ProviderConverter.java
index a9885bc..d1e6d52 100644
---
a/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/ProviderConverter.java
+++
b/configjsr/src/main/java/org/apache/tamaya/jsr382/converter/ProviderConverter.java
@@ -44,28 +44,29 @@ public class ProviderConverter implements
PropertyConverter<Provider> {
@Override
public Provider convert(String value, ConversionContext context) {
return () -> {
- try{
+ try {
Type targetType = context.getTargetType().getType();
ConvertQuery converter = new ConvertQuery(value,
TypeLiteral.of(targetType));
return context.getConfiguration().query(converter);
- }catch(Exception e){
+ } catch (Exception e) {
throw new ConfigException("Error evaluating config value.", e);
}
};
}
@Override
- public boolean equals(Object o){
+ public boolean equals(Object o) {
return getClass().equals(o.getClass());
}
@Override
- public int hashCode(){
+ public int hashCode() {
return getClass().hashCode();
}
/**
* A class for converting from a String to a particular type.
+ *
* @param <T> the ConfigQuery type
*/
private static final class ConvertQuery<T> implements ConfigQuery<T> {
@@ -83,17 +84,17 @@ public class ProviderConverter implements
PropertyConverter<Provider> {
List<PropertyConverter<T>> converters =
config.getContext().getPropertyConverters(type);
ConversionContext context = new
ConversionContext.Builder(type).setConfiguration(config)
.setConfiguration(config).setKey(ConvertQuery.class.getName()).build();
- for(PropertyConverter<?> conv: converters) {
- try{
- if(conv instanceof ProviderConverter){
+ for (PropertyConverter<?> conv : converters) {
+ try {
+ if (conv instanceof ProviderConverter) {
continue;
}
- T result = (T)conv.convert(rawValue, context);
- if(result!=null){
+ T result = (T) conv.convert(rawValue, context);
+ if (result != null) {
return result;
}
- }catch(Exception e){
- LOG.log(Level.FINEST, e, () -> "Converter "+ conv +"
failed to convert to " + type);
+ } catch (Exception e) {
+ LOG.log(Level.FINEST, e, () -> "Converter " + conv + "
failed to convert to " + type);
}
}
return null;