Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.smallrye.config;

import java.io.Serial;
import java.util.Set;

import jakarta.annotation.Priority;

Expand All @@ -28,14 +27,6 @@ public SecretKeysConfigSourceInterceptor(final PropertyNamesMatcher<?> secrets)
this.secrets = secrets;
}

@Deprecated(forRemoval = true)
public SecretKeysConfigSourceInterceptor(final Set<PropertyName> secrets) {
this.secrets = new PropertyNamesMatcher<>();
for (PropertyName secret : secrets) {
this.secrets.add(secret.getName());
}
}

@Override
public ConfigValue getValue(final ConfigSourceInterceptorContext context, final String name) {
// separate empty check to avoid PropertyName alloc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,26 +200,6 @@ public <T, C extends Collection<T>> C getValues(
}
}

@Deprecated(forRemoval = true)
public <T, C extends Collection<T>> C getIndexedValues(String name, Converter<T> converter,
IntFunction<C> collectionFactory) {
List<String> indexedProperties = getIndexedProperties(name);
if (indexedProperties.isEmpty()) {
throw new NoSuchElementException(ConfigMessages.msg.propertyNotFound(name));
}
return getIndexedValues(indexedProperties, converter, collectionFactory);
}

@Deprecated(forRemoval = true)
private <T, C extends Collection<T>> C getIndexedValues(List<String> indexedProperties, Converter<T> converter,
IntFunction<C> collectionFactory) {
C collection = collectionFactory.apply(indexedProperties.size());
for (String indexedProperty : indexedProperties) {
collection.add(getValue(indexedProperty, converter));
}
return collection;
}

public List<String> getIndexedProperties(final String property) {
Map<Integer, String> indexedProperties = configSources.getPropertyNames().indexed().get(property);
return indexedProperties == null ? Collections.emptyList() : indexedProperties.values().stream().toList();
Expand Down Expand Up @@ -535,23 +515,6 @@ public <T, C extends Collection<T>> Optional<C> getOptionalValues(final String n
}
}

@Deprecated(forRemoval = true)
public <T, C extends Collection<T>> Optional<C> getIndexedOptionalValues(String name, Converter<T> converter,
IntFunction<C> collectionFactory) {
List<String> indexedProperties = getIndexedProperties(name);
if (indexedProperties.isEmpty()) {
return Optional.empty();
}

C collection = collectionFactory.apply(indexedProperties.size());
for (String indexedProperty : indexedProperties) {
Optional<T> optionalValue = getOptionalValue(indexedProperty, converter);
optionalValue.ifPresent(collection::add);
}

return collection.isEmpty() ? Optional.empty() : Optional.of(collection);
}

@Override
public <K, V> Optional<Map<K, V>> getOptionalValues(
final String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,6 @@ public Defaults getDefaults() {
return defaults;
}

@Deprecated(forRemoval = true)
public Map<String, String> getDefaultValues() {
return defaults.getProperties();
}

public PropertyNamesMatcher<?> getSecretKeys() {
return secretKeys;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -181,8 +182,10 @@ void getIndexedValues() {
"server.environments[2]", "prod"))
.build();

List<String> environments = config.getIndexedValues("server.environments", config.requireConverter(String.class),
ArrayList::new);
List<String> environments = config.getValues(
"server.environments",
config.requireConverter(String.class),
(IntFunction<List<String>>) value -> new ArrayList<>());
assertEquals(3, environments.size());
assertEquals("dev", environments.get(0));
assertEquals("dev", config.getValue("server.environments[0]", String.class));
Expand All @@ -192,7 +195,10 @@ void getIndexedValues() {
assertEquals("prod", config.getValue("server.environments[2]", String.class));

assertThrows(NoSuchElementException.class,
() -> config.getIndexedValues("not.found", config.requireConverter(String.class), ArrayList::new));
() -> config.getValues(
"not.found",
config.requireConverter(String.class),
(IntFunction<List<String>>) value -> new ArrayList<>()));
}

@Test
Expand Down Expand Up @@ -298,17 +304,22 @@ void getOptionalValuesEmpty() {
.withSources(config("server.environments", ""))
.build();

assertFalse(
config.getIndexedOptionalValues("server.environments", config.requireConverter(String.class), ArrayList::new)
.isPresent());
assertFalse(config.getOptionalValues(
"server.environments",
config.requireConverter(String.class),
(IntFunction<Collection<String>>) value -> new ArrayList<>())
.isPresent());
assertFalse(config.getOptionalValues("server.environments", String.class).isPresent());

SmallRyeConfig configIndexed = new SmallRyeConfigBuilder()
.withSources(config("server.environments[0]", ""))
.build();

assertFalse(configIndexed
.getIndexedOptionalValues("server.environments", config.requireConverter(String.class), ArrayList::new)
.getOptionalValues(
"server.environments",
config.requireConverter(String.class),
(IntFunction<Collection<String>>) value -> new ArrayList<>())
.isPresent());
assertFalse(configIndexed.getOptionalValues("server.environments", String.class).isPresent());
}
Expand Down
Loading