Skip to content

Commit b1a5d8c

Browse files
authored
Remove Config.makeConfig (apple#1531)
This doesn't really make sense as part of the `Config` API. We can maybe make class `ConfigUtils` public, but, I don't know how useful it is anyways; it's more of an implementation detail.
1 parent 1571d72 commit b1a5d8c

4 files changed

Lines changed: 48 additions & 15 deletions

File tree

docs/modules/release-notes/pages/0.32.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ XXX
3131

3232
Things to watch out for when upgrading.
3333

34+
=== Removed Java APIs
35+
36+
The following APIs have been removed without replacement.
37+
38+
* `org.pkl.config.java.Config#makeConfig` (pr:https://github.com/apple/pkl/pull/1531[])
39+
3440
.XXX
3541
[%collapsible]
3642
====

pkl-config-java/src/main/java/org/pkl/config/java/Config.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package org.pkl.config.java;
1717

18+
import static org.pkl.config.java.ConfigUtils.makeConfig;
19+
1820
import java.io.InputStream;
1921
import java.lang.reflect.Type;
20-
import java.util.Map;
2122
import org.jspecify.annotations.Nullable;
2223
import org.pkl.config.java.mapper.ConversionException;
2324
import org.pkl.config.java.mapper.ValueMapper;
24-
import org.pkl.core.Composite;
2525
import org.pkl.core.Evaluator;
2626
import org.pkl.core.PklBinaryDecoder;
2727

@@ -30,6 +30,7 @@
3030
* using {@link #get(String)}. To consume the node's composite or scalar value, convert the value to
3131
* the desired Java type, using one of the provided {@link #as} methods.
3232
*/
33+
@SuppressWarnings("unused")
3334
public interface Config {
3435
/**
3536
* The dot-separated name of this node. For example, the node reached using {@code
@@ -110,14 +111,4 @@ static Config fromPklBinary(InputStream inputStream, ValueMapper mapper) {
110111
static Config fromPklBinary(InputStream inputStream) {
111112
return fromPklBinary(inputStream, ValueMapper.preconfigured());
112113
}
113-
114-
static Config makeConfig(Object decoded, ValueMapper mapper) {
115-
if (decoded instanceof Composite composite) {
116-
return new CompositeConfig("", mapper, composite);
117-
}
118-
if (decoded instanceof Map<?, ?> map) {
119-
return new MapConfig("", mapper, map);
120-
}
121-
return new LeafConfig("", mapper, decoded);
122-
}
123114
}

pkl-config-java/src/main/java/org/pkl/config/java/ConfigEvaluatorImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
2+
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
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,6 +15,8 @@
1515
*/
1616
package org.pkl.config.java;
1717

18+
import static org.pkl.config.java.ConfigUtils.makeConfig;
19+
1820
import org.pkl.config.java.mapper.ValueMapper;
1921
import org.pkl.core.Evaluator;
2022
import org.pkl.core.ModuleSource;
@@ -37,13 +39,13 @@ public Config evaluate(ModuleSource moduleSource) {
3739
@Override
3840
public Config evaluateOutputValue(ModuleSource moduleSource) {
3941
var value = evaluator.evaluateOutputValue(moduleSource);
40-
return Config.makeConfig(value, mapper);
42+
return makeConfig(value, mapper);
4143
}
4244

4345
@Override
4446
public Config evaluateExpression(ModuleSource moduleSource, String expression) {
4547
var value = evaluator.evaluateExpression(moduleSource, expression);
46-
return Config.makeConfig(value, mapper);
48+
return makeConfig(value, mapper);
4749
}
4850

4951
@Override
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright © 2026 Apple Inc. and the Pkl project authors. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.pkl.config.java;
17+
18+
import java.util.Map;
19+
import org.pkl.config.java.mapper.ValueMapper;
20+
import org.pkl.core.Composite;
21+
22+
class ConfigUtils {
23+
private ConfigUtils() {}
24+
25+
static Config makeConfig(Object decoded, ValueMapper mapper) {
26+
if (decoded instanceof Composite composite) {
27+
return new CompositeConfig("", mapper, composite);
28+
}
29+
if (decoded instanceof Map<?, ?> map) {
30+
return new MapConfig("", mapper, map);
31+
}
32+
return new LeafConfig("", mapper, decoded);
33+
}
34+
}

0 commit comments

Comments
 (0)