Initial commit

This commit is contained in:
Peter Niederwieser
2016-01-19 14:51:19 +01:00
committed by Dan Chao
commit ecad035dca
2972 changed files with 211653 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import org.pkl.core.Evaluator;
import org.pkl.core.ModuleSource;
import java.util.List;
import org.pkl.core.PModule;
import org.pkl.core.PObject;
import org.junit.jupiter.api.Test;
// the pkl/pkl-examples repo has a similar example
@SuppressWarnings({"unchecked", "unused", "ConstantConditions"})
public class CoreEvaluatorExample {
@Test
public void usage() {
// tag::usage[]
PModule module;
try (var evaluator =
Evaluator.preconfigured()) { // <1>
module = evaluator.evaluate(
ModuleSource.text("pigeon { age = 30; hobbies = List(\"swimming\", \"surfing\") }")); // <2>
}
var pigeon = (PObject) module.get("pigeon"); // <3>
var className = pigeon.getClassInfo().getQualifiedName(); // <4>
var hobbies = (List<String>) pigeon.get("hobbies"); // <5>
// end::usage[]
}
}