Skip to content

Commit

Permalink
Public API to get a ConfigMapping interface or class (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez authored Mar 31, 2023
1 parent 5ee9ca0 commit 9b2d355
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public static List<ConfigMappingMetadata> getConfigMappingsMetadata(Class<?> typ
final ConfigMappingClass configMappingClass = ConfigMappingClass.getConfigurationClass(type);
if (configMappingClass != null) {
mappings.add(configMappingClass);
mappings.addAll(getConfigMappingsMetadata(getConfigMappingInterface(type).getInterfaceType()));
mappings.addAll(getConfigMappingsMetadata(getConfigMapping(type).getInterfaceType()));
}
return mappings;
}

static ConfigMappingInterface getConfigMappingInterface(final Class<?> type) {
public static ConfigMappingInterface getConfigMapping(final Class<?> type) {
return ConfigMappingInterface.getConfigurationInterface(getConfigMappingClass(type));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import static io.smallrye.config.ConfigMappingInterface.MapProperty;
import static io.smallrye.config.ConfigMappingInterface.PrimitiveProperty;
import static io.smallrye.config.ConfigMappingInterface.Property;
import static io.smallrye.config.ConfigMappingLoader.getConfigMapping;
import static io.smallrye.config.ConfigMappingLoader.getConfigMappingClass;
import static io.smallrye.config.ConfigMappingLoader.getConfigMappingInterface;
import static io.smallrye.config.SmallRyeConfig.SMALLRYE_CONFIG_MAPPING_VALIDATE_UNKNOWN;
import static io.smallrye.config.common.utils.StringUtil.replaceNonAlphanumericByUnderscores;
import static java.lang.Integer.parseInt;
Expand Down Expand Up @@ -80,7 +80,7 @@ final class ConfigMappingProvider implements Serializable {
// construct the lazy match actions for each group
BiFunction<ConfigMappingContext, NameIterator, ConfigMappingObject> ef = new GetRootAction(root,
entry.getKey());
ConfigMappingInterface mapping = getConfigMappingInterface(root);
ConfigMappingInterface mapping = getConfigMapping(root);
processEagerGroup(currentPath, matchActions, defaultValues, mapping.getNamingStrategy(), mapping, ef);
}
currentPath.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void loadManually() {

@Test
void discoverNested() {
ConfigMappingInterface mapping = ConfigMappingLoader.getConfigMappingInterface(ServerNested.class);
ConfigMappingInterface mapping = ConfigMappingLoader.getConfigMapping(ServerNested.class);
List<ConfigMappingInterface> nested = mapping.getNested();
assertEquals(4, nested.size());
List<Class<?>> types = nested.stream().map(ConfigMappingInterface::getInterfaceType).collect(toList());
Expand Down

0 comments on commit 9b2d355

Please sign in to comment.