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
6 changes: 6 additions & 0 deletions docs/modules/release-notes/pages/0.32.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
====
Expand Down
15 changes: 3 additions & 12 deletions pkl-config-java/src/main/java/org/pkl/config/java/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -30,6 +30,7 @@
* 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
Expand Down Expand Up @@ -110,14 +111,4 @@ static Config fromPklBinary(InputStream inputStream, ValueMapper mapper) {
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);
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -37,13 +39,13 @@ public Config evaluate(ModuleSource moduleSource) {
@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
Expand Down
34 changes: 34 additions & 0 deletions pkl-config-java/src/main/java/org/pkl/config/java/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading