-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7209 from TouK/1.18-ports5
1.18 ports5
- Loading branch information
Showing
69 changed files
with
1,084 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
components-api/src/main/scala/pl/touk/nussknacker/engine/api/json/FromJsonDecoder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package pl.touk.nussknacker.engine.api.json | ||
|
||
import io.circe.Json | ||
import pl.touk.nussknacker.engine.util.Implicits._ | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
object FromJsonDecoder { | ||
|
||
def jsonToAny(json: Json): Any = json.fold( | ||
jsonNull = null, | ||
jsonBoolean = identity[Boolean], | ||
jsonNumber = jsonNumber => | ||
// we pick the narrowest type as possible to reduce the amount of memory and computations overheads | ||
jsonNumber.toInt orElse | ||
jsonNumber.toLong orElse | ||
// We prefer java big decimal over float/double | ||
jsonNumber.toBigDecimal.map(_.bigDecimal) | ||
getOrElse (throw new IllegalArgumentException(s"Not supported json number: $jsonNumber")), | ||
jsonString = identity[String], | ||
jsonArray = _.map(jsonToAny).asJava, | ||
jsonObject = _.toMap.mapValuesNow(jsonToAny).asJava | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
components-api/src/test/scala/pl/touk/nussknacker/engine/api/json/FromJsonDecoderTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pl.touk.nussknacker.engine.api.json | ||
|
||
import io.circe.Json | ||
import org.scalatest.OptionValues | ||
import org.scalatest.funsuite.AnyFunSuiteLike | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class FromJsonDecoderTest extends AnyFunSuiteLike with Matchers with OptionValues { | ||
|
||
test("json number decoding pick the narrowest type") { | ||
FromJsonDecoder.jsonToAny(Json.fromInt(1)) shouldBe 1 | ||
FromJsonDecoder.jsonToAny(Json.fromInt(Integer.MAX_VALUE)) shouldBe Integer.MAX_VALUE | ||
FromJsonDecoder.jsonToAny(Json.fromLong(Long.MaxValue)) shouldBe Long.MaxValue | ||
FromJsonDecoder.jsonToAny( | ||
Json.fromBigDecimal(java.math.BigDecimal.valueOf(Double.MaxValue)) | ||
) shouldBe java.math.BigDecimal.valueOf(Double.MaxValue) | ||
val moreThanLongMaxValue = BigDecimal(Long.MaxValue) * 10 | ||
FromJsonDecoder.jsonToAny(Json.fromBigDecimal(moreThanLongMaxValue)) shouldBe moreThanLongMaxValue.bigDecimal | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+84 Bytes
(100%)
...nux/Expression suggester should display colorfull and sorted completions #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.17 KB
(130%)
...nux/Expression suggester should display colorfull and sorted completions #1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-304 Bytes
(99%)
...d allow adding input parameters and display used fragment graph in modal #7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.