Skip to content

Commit 88ddd36

Browse files
authored
Use helidon-common-config where possible/applicable (helidon-io#6448)
1 parent 570893b commit 88ddd36

93 files changed

Lines changed: 193 additions & 178 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/config/src/main/java/io/helidon/common/config/Config.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -225,6 +225,18 @@ default Config get(Key key) {
225225
*/
226226
<T> ConfigValue<List<T>> asList(Class<T> type) throws ConfigException;
227227

228+
/**
229+
* Returns a list of child {@code Config} nodes if the node is {@code Type#OBJECT}.
230+
* Returns a list of element nodes if the node is {@code Type#LIST}.
231+
* Throws {@code MissingValueException} if the node is {@code Type#MISSING}.
232+
* Otherwise, if node is {@code Type#VALUE}, it throws {@code ConfigMappingException}.
233+
*
234+
* @return a list of {@code Type#OBJECT} members or a list of {@code Type#LIST} members
235+
* @param <C> the common config derived type
236+
* @throws io.helidon.common.config.ConfigException in case the node is {@code Type#VALUE}
237+
*/
238+
<C extends Config> ConfigValue<List<C>> asNodeList() throws ConfigException;
239+
228240
/**
229241
* Transform all leaf nodes (values) into Map instance.
230242
*

config/config/src/main/java/io/helidon/config/Config.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,8 @@ default ConfigValue<Config> asNode() {
827827
Config::asNode);
828828
}
829829

830-
/**
831-
* Returns a list of child {@code Config} nodes if the node is {@link Type#OBJECT}.
832-
* Returns a list of element nodes if the node is {@link Type#LIST}.
833-
* Throws {@link MissingValueException} if the node is {@link Type#MISSING}.
834-
* Otherwise, if node is {@link Type#VALUE}, it throws {@link ConfigMappingException}.
835-
*
836-
* @return a list of {@link Type#OBJECT} members or a list of {@link Type#LIST} members
837-
* @throws ConfigMappingException in case the node is {@link Type#VALUE}
838-
*/
830+
@Override
831+
@SuppressWarnings("unchecked")
839832
ConfigValue<List<Config>> asNodeList() throws ConfigMappingException;
840833

841834
/**

cors/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
<dependencies>
3333
<dependency>
34-
<groupId>io.helidon.config</groupId>
35-
<artifactId>helidon-config</artifactId>
34+
<groupId>io.helidon.common</groupId>
35+
<artifactId>helidon-common-config</artifactId>
3636
</dependency>
3737
<dependency>
3838
<groupId>io.helidon.common</groupId>

cors/src/main/java/io/helidon/cors/Aggregator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,11 +22,11 @@
2222
import java.util.function.Supplier;
2323
import java.util.logging.Logger;
2424

25+
import io.helidon.common.config.Config;
26+
import io.helidon.common.config.ConfigValue;
2527
import io.helidon.common.http.PathMatcher;
2628
import io.helidon.common.http.PathMatchers;
2729
import io.helidon.common.uri.UriPath;
28-
import io.helidon.config.Config;
29-
import io.helidon.config.ConfigValue;
3030
import io.helidon.cors.LogHelper.MatcherChecks;
3131

3232
/**
@@ -118,7 +118,7 @@ public Aggregator build() {
118118

119119
Builder config(Config config) {
120120
if (config.exists()) {
121-
ConfigValue<CrossOriginConfig.Builder> configValue = config.as(CrossOriginConfig::builder);
121+
ConfigValue<CrossOriginConfig.Builder> configValue = config.map(CrossOriginConfig::builder);
122122
if (configValue.isPresent()) {
123123
CrossOriginConfig crossOriginConfig = configValue.get().build();
124124
addPathlessCrossOrigin(crossOriginConfig);
@@ -136,7 +136,7 @@ Builder config(Config config) {
136136
Builder mappedConfig(Config config) {
137137

138138
if (config.exists()) {
139-
ConfigValue<MappedCrossOriginConfig.Builder> mappedConfigValue = config.as(MappedCrossOriginConfig::builder);
139+
ConfigValue<MappedCrossOriginConfig.Builder> mappedConfigValue = config.map(MappedCrossOriginConfig::builder);
140140
if (mappedConfigValue.isPresent()) {
141141
MappedCrossOriginConfig mapped = mappedConfigValue.get().build();
142142
/*

cors/src/main/java/io/helidon/cors/CorsSupportBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
2121
import java.util.logging.Level;
2222
import java.util.logging.Logger;
2323

24-
import io.helidon.config.Config;
24+
import io.helidon.common.config.Config;
2525

2626
/**
2727
* A Helidon service and handler implementation that implements CORS, for both the application and for built-in Helidon

cors/src/main/java/io/helidon/cors/CorsSupportHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,9 +28,9 @@
2828
import java.util.function.Supplier;
2929
import java.util.logging.Logger;
3030

31+
import io.helidon.common.config.Config;
3132
import io.helidon.common.http.Http;
3233
import io.helidon.common.http.Http.Header;
33-
import io.helidon.config.Config;
3434
import io.helidon.cors.LogHelper.Headers;
3535

3636
import static io.helidon.cors.LogHelper.DECISION_LEVEL;

cors/src/main/java/io/helidon/cors/CrossOriginConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818

1919
import java.util.Arrays;
2020

21-
import io.helidon.config.Config;
21+
import io.helidon.common.config.Config;
2222
import io.helidon.config.metadata.Configured;
2323
import io.helidon.config.metadata.ConfiguredOption;
2424

cors/src/main/java/io/helidon/cors/Loader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
1515
*/
1616
package io.helidon.cors;
1717

18-
import io.helidon.config.Config;
19-
import io.helidon.config.ConfigValue;
18+
import io.helidon.common.config.Config;
19+
import io.helidon.common.config.ConfigValue;
2020

2121
import static io.helidon.cors.Aggregator.PATHLESS_KEY;
2222
import static io.helidon.cors.CrossOriginConfig.CORS_PATHS_CONFIG_KEY;
@@ -78,7 +78,7 @@ static MappedCrossOriginConfig.Builder applyConfig(MappedCrossOriginConfig.Build
7878
if (!item.exists()) {
7979
break;
8080
}
81-
ConfigValue<CrossOriginConfig.Builder> basicConfigValue = item.as(CrossOriginConfig::builder);
81+
ConfigValue<CrossOriginConfig.Builder> basicConfigValue = item.map(CrossOriginConfig::builder);
8282
if (!basicConfigValue.isPresent()) {
8383
continue;
8484
}

cors/src/main/java/io/helidon/cors/MappedCrossOriginConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import java.util.Optional;
2323
import java.util.function.BiConsumer;
2424

25-
import io.helidon.config.Config;
25+
import io.helidon.common.config.Config;
2626

2727
/**
2828
* Cross-origin {@link CrossOriginConfig} instances linked to paths, plus an {@code enabled} setting. Most developers will not

cors/src/main/java/module-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
module io.helidon.cors {
2121
requires java.logging;
2222
requires io.helidon.common.http;
23-
requires io.helidon.config;
23+
requires io.helidon.common.config;
2424

2525
requires static io.helidon.config.metadata;
2626

0 commit comments

Comments
 (0)