Skip to content

Commit da35535

Browse files
Merge pull request #733 from Netflix/warnings-cleanup
Cleanup a few compiler warnings and improve some javadocs.
2 parents 8eb1958 + 8f1bb90 commit da35535

File tree

4 files changed

+40
-26
lines changed

4 files changed

+40
-26
lines changed

archaius2-api/src/main/java/com/netflix/archaius/api/Config.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,26 @@ default boolean instrumentationEnabled() {
135135

136136
/**
137137
* Get the property as a list. Depending on the underlying implementation the list
138-
* may be derived from a comma delimited string or from an actual list structure.
139-
* @param key
140-
* @return
138+
* may be derived from a comma-delimited string or from an actual list structure.
139+
* @deprecated Use {@link #getList(String, Class)} instead.
141140
*/
142141
List<?> getList(String key);
143-
142+
143+
/**
144+
* Get the property as a list. Depending on the underlying implementation the list
145+
* may be derived from a comma-delimited string or from an actual list structure.
146+
*/
144147
<T> List<T> getList(String key, Class<T> type);
145-
148+
149+
/**
150+
* Get the property as a list. Depending on the underlying implementation the list
151+
* may be derived from a comma-delimited string or from an actual list structure.
152+
* This method is inherently unsafe and should be used with caution. The type of the list may change
153+
* depending on whether the key is defined or not, because the parser can't know the type of the defaultValue's
154+
* elements.
155+
* @deprecated Use {@link #getList(String, Class)} instead.
156+
*/
157+
@Deprecated
146158
List<?> getList(String key, List<?> defaultValue);
147159

148160
/**

archaius2-api/src/main/java/com/netflix/archaius/api/PropertyContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* of Property are non-blocking and optimize updating property values
2727
* in the background so as not to incur any overhead during hot call
2828
* paths.
29+
* @deprecated Use {@link Property} instead.
2930
*/
3031
@Deprecated
3132
public interface PropertyContainer {

archaius2-api/src/main/java/com/netflix/archaius/api/PropertyFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
*/
1616
package com.netflix.archaius.api;
1717

18+
import java.lang.reflect.Type;
19+
1820
/**
1921
* Factory of Property objects.
2022
*
2123
* @see Property
22-
* @deprecated Deprecated in favor of using PropertyRepository
24+
* @deprecated Deprecated in favor of {@link PropertyRepository}
2325
*/
2426
@Deprecated
2527
public interface PropertyFactory extends PropertyRepository {
2628
/**
27-
* Create a property for the property name.
29+
* Create a property for the property name.
30+
* @deprecated Use {@link PropertyRepository#get(String, Type)} instead.
2831
*/
32+
@Deprecated
2933
PropertyContainer getProperty(String propName);
3034
}

archaius2-commons-configuration/src/main/java/com/netflix/archaius/commons/CommonsToConfig.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.ArrayList;
1919
import java.util.Iterator;
2020
import java.util.List;
21-
import java.util.function.BiConsumer;
2221

2322
import org.apache.commons.configuration.AbstractConfiguration;
2423
import org.apache.commons.lang.StringUtils;
@@ -59,16 +58,18 @@ public Iterator<String> getKeys() {
5958

6059
@Override
6160
public <T> List<T> getList(String key, Class<T> type) {
62-
List value = config.getList(key);
61+
List<?> value = config.getList(key);
6362
if (value == null) {
6463
return notFound(key);
6564
}
66-
;
67-
List<T> result = new ArrayList<T>();
65+
66+
List<T> result = new ArrayList<>();
6867
for (Object part : value) {
6968
if (type.isInstance(part)) {
70-
result.add((T)part);
69+
//noinspection unchecked
70+
result.add((T) part);
7171
} else if (part instanceof String) {
72+
//noinspection deprecation
7273
result.add(getDecoder().decode(type, (String) part));
7374
} else {
7475
throw new UnsupportedOperationException(
@@ -79,8 +80,8 @@ public <T> List<T> getList(String key, Class<T> type) {
7980
}
8081

8182
@Override
82-
public List getList(String key) {
83-
List value = config.getList(key);
83+
public List<?> getList(String key) {
84+
List<?> value = config.getList(key);
8485
if (value == null) {
8586
return notFound(key);
8687
}
@@ -89,28 +90,24 @@ public List getList(String key) {
8990

9091
@Override
9192
public String getString(String key, String defaultValue) {
92-
List value = config.getList(key);
93+
List<?> value = config.getList(key);
9394
if (value == null) {
9495
return notFound(key, defaultValue != null ? getStrInterpolator().create(getLookup()).resolve(defaultValue) : null);
9596
}
96-
List<String> interpolatedResult = new ArrayList<>();
97-
for (Object part : value) {
98-
if (part instanceof String) {
99-
interpolatedResult.add(getStrInterpolator().create(getLookup()).resolve(part.toString()));
100-
} else {
101-
throw new UnsupportedOperationException(
102-
"Property values other than String not supported");
103-
}
104-
}
105-
return StringUtils.join(interpolatedResult, getListDelimiter());
97+
return interpolateAndConcat(value);
10698
}
10799

108100
@Override
109101
public String getString(String key) {
110-
List value = config.getList(key);
102+
List<?> value = config.getList(key);
111103
if (value == null) {
112104
return notFound(key);
113105
}
106+
return interpolateAndConcat(value);
107+
}
108+
109+
110+
private String interpolateAndConcat(List<?> value) {
114111
List<String> interpolatedResult = new ArrayList<>();
115112
for (Object part : value) {
116113
if (part instanceof String) {

0 commit comments

Comments
 (0)