diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/TimelineRemoteTests.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/TimelineRemoteTests.java index b025dcd112..489d1dd659 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/TimelineRemoteTests.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/TimelineRemoteTests.java @@ -136,7 +136,7 @@ void queryActivityDirectives() { @Test void queryResources() { - final var fruit = simulatedPlan.resource("/fruit", Real::deserialize).collect(); + final var fruit = simulatedPlan.resource("/fruit", Real.deserialize()).collect(); assertIterableEquals( List.of( Segment.of(Interval.betweenClosedOpen(Duration.ZERO, Duration.HOUR), new LinearEquation(4.0)), diff --git a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/constraints/ConstFruit.java b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/constraints/ConstFruit.java index c934c367bd..be5823afd9 100644 --- a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/constraints/ConstFruit.java +++ b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/constraints/ConstFruit.java @@ -11,7 +11,7 @@ public class ConstFruit implements Constraint { @NotNull @Override public Violations run(SimulatedPlan plan, @NotNull CollectOptions options) { - final var fruit = plan.resource("/fruit", Real::deserialize); + final var fruit = plan.resource("/fruit", Real.deserialize()); return Violations.violateOn( fruit.equalTo(4), diff --git a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SimulationDemo.java b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SimulationDemo.java index 7fbed12fc2..7d018462d2 100644 --- a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SimulationDemo.java +++ b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/SimulationDemo.java @@ -29,7 +29,7 @@ public void run(EditablePlan plan) { var simResults = plan.latestResults(); if (simResults == null) simResults = plan.simulate(); - final var lowFruit = simResults.resource("/fruit", Real::deserialize).lessThan(3.5).isolateTrue(); + final var lowFruit = simResults.resource("/fruit", Real.deserialize()).lessThan(3.5).isolateTrue(); final var bites = simResults.instances("BiteBanana"); final var connections = lowFruit.starts().shift(Duration.MINUTE.negate()) diff --git a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/StayWellFed.java b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/StayWellFed.java index aa42e74816..0e5dbb7335 100644 --- a/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/StayWellFed.java +++ b/procedural/examples/foo-procedures/src/main/java/gov/nasa/ammos/aerie/procedural/examples/fooprocedures/procedures/StayWellFed.java @@ -49,7 +49,7 @@ public void run(@NotNull final EditablePlan plan) { // I'm using producer as a substitute for a mission phase variable. // This goal will only apply during the Dole mission phase. :) final var dolePhase = simResults - .resource("/producer", Strings::deserialize) + .resource("/producer", Strings.deserialize()) .highlightEqualTo("Dole") .cache(); @@ -91,7 +91,7 @@ public void run(@NotNull final EditablePlan plan) { // So we iteratively find the first time /fruit drops below zero // and add a grow banana fix it. We then mock the effect of grow banana // by adding one to /fruit, rather than resimulating, and do it again. - var fruit = simResults.resource("/fruit", Real::deserialize).cache(); + var fruit = simResults.resource("/fruit", Real.deserialize()).cache(); var ranOutAt = fruit.lessThan(0).filterByWindows(dolePhase, true).risingEdges().highlightTrue().collect(); while (!ranOutAt.isEmpty()) { diff --git a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Booleans.kt b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Booleans.kt index 709549bddf..7ae7b215e6 100644 --- a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Booleans.kt +++ b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Booleans.kt @@ -119,6 +119,8 @@ data class Booleans(private val timeline: Timeline, Booleans>): * Converts a list of serialized value segments into a [Booleans] profile; * for use with [gov.nasa.ammos.aerie.procedural.timeline.plan.Plan.resource]. */ - @JvmStatic fun deserialize(list: List>) = Booleans(list.map { it.withNewValue(it.value.asBoolean().get()) }) + @JvmStatic fun deserialize() = { list: List> -> + Booleans(list.map { it.withNewValue(it.value.asBoolean().get()) }) + } } } diff --git a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Numbers.kt b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Numbers.kt index 3de00c0085..9ffdd32069 100644 --- a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Numbers.kt +++ b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Numbers.kt @@ -214,7 +214,7 @@ data class Numbers(private val timeline: Timeline, Numbers * * Prefers converting to longs if possible, and falls back to doubles if not. */ - @JvmStatic fun deserialize(list: List>) = Numbers(list.map { seg -> + @JvmStatic fun deserialize() = { list: List> -> Numbers(list.map { seg -> val bigDecimal = seg.value.asNumeric().orElseThrow { Exception("value was not numeric: $seg") } val number: Number = try { bigDecimal.longValueExact() @@ -222,6 +222,6 @@ data class Numbers(private val timeline: Timeline, Numbers bigDecimal.toDouble() } seg.withNewValue(number) - }) + }) } } } diff --git a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Real.kt b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Real.kt index 8f06967158..ba3b01de7f 100644 --- a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Real.kt +++ b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Real.kt @@ -210,7 +210,7 @@ data class Real(private val timeline: Timeline, Real>): * While plain numbers are acceptable and will be converted to a [LinearEquation] without warning, consider using [Numbers] * to keep the precision. */ - @JvmStatic fun deserialize(list: List>): Real { + @JvmStatic fun deserialize() = { list: List> -> val converted: List> = list.map { s -> s.value.asReal().getOrNull()?.let { return@map s.withNewValue(LinearEquation(it)) } val map = s.value.asMap().orElseThrow { RealDeserializeException("value was not a map or plain number: $s") } @@ -221,7 +221,7 @@ data class Real(private val timeline: Timeline, Real>): .asReal().orElseThrow { RealDeserializeException("rate was not a double") } s.withNewValue(LinearEquation(s.interval.start, initialValue, rate)) } - return Real(converted) + Real(converted) } /***/ class RealDeserializeException(message: String): Exception(message) diff --git a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Strings.kt b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Strings.kt index 78ce7840c6..bf8bc9901c 100644 --- a/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Strings.kt +++ b/procedural/timeline/src/main/kotlin/gov/nasa/ammos/aerie/procedural/timeline/collections/profiles/Strings.kt @@ -52,9 +52,11 @@ data class Strings(private val timeline: Timeline, Strings>): * Converts a list of serialized value segments into a [Strings] profile; * for use with [gov.nasa.ammos.aerie.procedural.timeline.plan.Plan.resource]. */ - @JvmStatic fun deserialize(list: List>) = Strings(list.map { seg -> - val string = seg.value.asString().orElseThrow { Exception("value was not a string: $seg") } - seg.withNewValue(string) - }) + @JvmStatic fun deserialize() = { list: List> -> + Strings(list.map { seg -> + val string = seg.value.asString().orElseThrow { Exception("value was not a string: $seg") } + seg.withNewValue(string) + }) + } } }