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

Cleanup a few compiler warnings and improve some javadocs. #733

Merged
merged 1 commit into from
Sep 25, 2024
Merged
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: 17 additions & 5 deletions archaius2-api/src/main/java/com/netflix/archaius/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,26 @@ default boolean instrumentationEnabled() {

/**
* Get the property as a list. Depending on the underlying implementation the list
* may be derived from a comma delimited string or from an actual list structure.
* @param key
* @return
* may be derived from a comma-delimited string or from an actual list structure.
* @deprecated Use {@link #getList(String, Class)} instead.
*/
List<?> getList(String key);


/**
* Get the property as a list. Depending on the underlying implementation the list
* may be derived from a comma-delimited string or from an actual list structure.
*/
<T> List<T> getList(String key, Class<T> type);


/**
* Get the property as a list. Depending on the underlying implementation the list
* may be derived from a comma-delimited string or from an actual list structure.
* This method is inherently unsafe and should be used with caution. The type of the list may change
* depending on whether the key is defined or not, because the parser can't know the type of the defaultValue's
* elements.
* @deprecated Use {@link #getList(String, Class)} instead.
*/
@Deprecated
List<?> getList(String key, List<?> defaultValue);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* of Property are non-blocking and optimize updating property values
* in the background so as not to incur any overhead during hot call
* paths.
* @deprecated Use {@link Property} instead.
*/
@Deprecated
public interface PropertyContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
*/
package com.netflix.archaius.api;

import java.lang.reflect.Type;

/**
* Factory of Property objects.
*
* @see Property
* @deprecated Deprecated in favor of using PropertyRepository
* @deprecated Deprecated in favor of {@link PropertyRepository}
*/
@Deprecated
public interface PropertyFactory extends PropertyRepository {
/**
* Create a property for the property name.
* Create a property for the property name.
* @deprecated Use {@link PropertyRepository#get(String, Type)} instead.
*/
@Deprecated
PropertyContainer getProperty(String propName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.BiConsumer;

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

@Override
public <T> List<T> getList(String key, Class<T> type) {
List value = config.getList(key);
List<?> value = config.getList(key);
if (value == null) {
return notFound(key);
}
;
List<T> result = new ArrayList<T>();

List<T> result = new ArrayList<>();
for (Object part : value) {
if (type.isInstance(part)) {
result.add((T)part);
//noinspection unchecked
result.add((T) part);
} else if (part instanceof String) {
//noinspection deprecation
result.add(getDecoder().decode(type, (String) part));
} else {
throw new UnsupportedOperationException(
Expand All @@ -79,8 +80,8 @@ public <T> List<T> getList(String key, Class<T> type) {
}

@Override
public List getList(String key) {
List value = config.getList(key);
public List<?> getList(String key) {
List<?> value = config.getList(key);
if (value == null) {
return notFound(key);
}
Expand All @@ -89,28 +90,24 @@ public List getList(String key) {

@Override
public String getString(String key, String defaultValue) {
List value = config.getList(key);
List<?> value = config.getList(key);
if (value == null) {
return notFound(key, defaultValue != null ? getStrInterpolator().create(getLookup()).resolve(defaultValue) : null);
}
List<String> interpolatedResult = new ArrayList<>();
for (Object part : value) {
if (part instanceof String) {
interpolatedResult.add(getStrInterpolator().create(getLookup()).resolve(part.toString()));
} else {
throw new UnsupportedOperationException(
"Property values other than String not supported");
}
}
return StringUtils.join(interpolatedResult, getListDelimiter());
return interpolateAndConcat(value);
}

@Override
public String getString(String key) {
List value = config.getList(key);
List<?> value = config.getList(key);
if (value == null) {
return notFound(key);
}
return interpolateAndConcat(value);
}


private String interpolateAndConcat(List<?> value) {
List<String> interpolatedResult = new ArrayList<>();
for (Object part : value) {
if (part instanceof String) {
Expand Down
Loading