diff --git a/docs/modules/release-notes/pages/0.32.adoc b/docs/modules/release-notes/pages/0.32.adoc index 45caa83c..699bb4ef 100644 --- a/docs/modules/release-notes/pages/0.32.adoc +++ b/docs/modules/release-notes/pages/0.32.adoc @@ -31,6 +31,12 @@ XXX Things to watch out for when upgrading. +=== Removed Java APIs + +The following APIs have been removed without replacement. + +* `org.pkl.config.java.Config#makeConfig` (pr:https://github.com/apple/pkl/pull/1531[]) + .XXX [%collapsible] ==== diff --git a/pkl-config-java/src/main/java/org/pkl/config/java/Config.java b/pkl-config-java/src/main/java/org/pkl/config/java/Config.java index 77552733..090d52db 100644 --- a/pkl-config-java/src/main/java/org/pkl/config/java/Config.java +++ b/pkl-config-java/src/main/java/org/pkl/config/java/Config.java @@ -15,13 +15,13 @@ */ package org.pkl.config.java; +import static org.pkl.config.java.ConfigUtils.makeConfig; + import java.io.InputStream; import java.lang.reflect.Type; -import java.util.Map; import org.jspecify.annotations.Nullable; import org.pkl.config.java.mapper.ConversionException; import org.pkl.config.java.mapper.ValueMapper; -import org.pkl.core.Composite; import org.pkl.core.Evaluator; import org.pkl.core.PklBinaryDecoder; @@ -30,6 +30,7 @@ import org.pkl.core.PklBinaryDecoder; * using {@link #get(String)}. To consume the node's composite or scalar value, convert the value to * the desired Java type, using one of the provided {@link #as} methods. */ +@SuppressWarnings("unused") public interface Config { /** * The dot-separated name of this node. For example, the node reached using {@code @@ -110,14 +111,4 @@ public interface Config { static Config fromPklBinary(InputStream inputStream) { return fromPklBinary(inputStream, ValueMapper.preconfigured()); } - - static Config makeConfig(Object decoded, ValueMapper mapper) { - if (decoded instanceof Composite composite) { - return new CompositeConfig("", mapper, composite); - } - if (decoded instanceof Map map) { - return new MapConfig("", mapper, map); - } - return new LeafConfig("", mapper, decoded); - } } diff --git a/pkl-config-java/src/main/java/org/pkl/config/java/ConfigEvaluatorImpl.java b/pkl-config-java/src/main/java/org/pkl/config/java/ConfigEvaluatorImpl.java index 937c0d56..41c40677 100644 --- a/pkl-config-java/src/main/java/org/pkl/config/java/ConfigEvaluatorImpl.java +++ b/pkl-config-java/src/main/java/org/pkl/config/java/ConfigEvaluatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. + * Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package org.pkl.config.java; +import static org.pkl.config.java.ConfigUtils.makeConfig; + import org.pkl.config.java.mapper.ValueMapper; import org.pkl.core.Evaluator; import org.pkl.core.ModuleSource; @@ -37,13 +39,13 @@ final class ConfigEvaluatorImpl implements ConfigEvaluator { @Override public Config evaluateOutputValue(ModuleSource moduleSource) { var value = evaluator.evaluateOutputValue(moduleSource); - return Config.makeConfig(value, mapper); + return makeConfig(value, mapper); } @Override public Config evaluateExpression(ModuleSource moduleSource, String expression) { var value = evaluator.evaluateExpression(moduleSource, expression); - return Config.makeConfig(value, mapper); + return makeConfig(value, mapper); } @Override diff --git a/pkl-config-java/src/main/java/org/pkl/config/java/ConfigUtils.java b/pkl-config-java/src/main/java/org/pkl/config/java/ConfigUtils.java new file mode 100644 index 00000000..6c911018 --- /dev/null +++ b/pkl-config-java/src/main/java/org/pkl/config/java/ConfigUtils.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2026 Apple Inc. and the Pkl project authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.config.java; + +import java.util.Map; +import org.pkl.config.java.mapper.ValueMapper; +import org.pkl.core.Composite; + +class ConfigUtils { + private ConfigUtils() {} + + static Config makeConfig(Object decoded, ValueMapper mapper) { + if (decoded instanceof Composite composite) { + return new CompositeConfig("", mapper, composite); + } + if (decoded instanceof Map map) { + return new MapConfig("", mapper, map); + } + return new LeafConfig("", mapper, decoded); + } +}