From 89ed14ae1bcc5c2af1755faeeb8b5c717b175aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bigorajski?= <72501021+lukasz-bigorajski@users.noreply.github.com> Date: Wed, 13 Nov 2024 19:32:59 +0100 Subject: [PATCH] =?UTF-8?q?[NU-1836]=20Rename=20is=20conversion=20method?= =?UTF-8?q?=20and=20add=20from=20string=20conversions=E2=80=A6=20(#7135)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/api/ExpressionSuggesterSpec.scala | 30 +- docs/Changelog.md | 14 +- .../resources/extractedTypes/devCreator.json | 1206 ++++++++-------- .../extractedTypes/defaultModel.json | 1214 ++++++++--------- .../extension/CastOrConversionExt.scala | 53 +- .../engine/extension/Conversion.scala | 18 +- .../engine/extension/ConversionExt.scala | 25 +- .../extension/ToListConversionExt.scala | 7 +- .../engine/extension/ToMapConversionExt.scala | 7 +- .../extension/ExtensionMethodsSpec.scala | 24 +- .../engine/spel/SpelExpressionSpec.scala | 173 ++- 11 files changed, 1430 insertions(+), 1341 deletions(-) diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ExpressionSuggesterSpec.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ExpressionSuggesterSpec.scala index 3245be70acb..29068d3e4ff 100644 --- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ExpressionSuggesterSpec.scala +++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/ExpressionSuggesterSpec.scala @@ -24,7 +24,10 @@ import pl.touk.nussknacker.test.PatientScalaFutures import pl.touk.nussknacker.ui.api.ExpressionSuggesterTestData._ import pl.touk.nussknacker.ui.suggester.ExpressionSuggester -import java.time.{Duration, LocalDateTime} +import java.nio.charset.Charset +import java.time.chrono.{ChronoLocalDate, ChronoLocalDateTime} +import java.time.{Duration, LocalDate, LocalDateTime, LocalTime, ZoneId, ZoneOffset} +import java.util.{Currency, Locale, UUID} import scala.collection.immutable.ListMap import scala.concurrent.ExecutionContext import scala.jdk.CollectionConverters._ @@ -116,7 +119,7 @@ class ExpressionSuggesterSpec ), ClassDefinition( Unknown, - Map("is" -> List(StaticMethodDefinition(MethodTypeInfo(Nil, None, Typed[Boolean]), "is", None))), + Map("canBe" -> List(StaticMethodDefinition(MethodTypeInfo(Nil, None, Typed[Boolean]), "canBe", None))), Map.empty ), ) @@ -775,7 +778,7 @@ class ExpressionSuggesterSpec test("should suggest methods for unknown") { spelSuggestionsFor("#unknown.") shouldBe List( - suggestion("is", Typed[Boolean]), + suggestion("canBe", Typed[Boolean]), ) } @@ -801,6 +804,16 @@ class ExpressionSuggesterSpec suggestion("String", Typed[java.lang.String]), suggestion("List", Typed.genericTypeClass[java.util.List[_]](List(Unknown))), suggestion("Map", Typed.genericTypeClass[java.util.Map[_, _]](List(Unknown, Unknown))), + suggestion("Charset", Typed[Charset]), + suggestion("ChronoLocalDate", Typed[ChronoLocalDate]), + suggestion("ChronoLocalDateTime", Typed[ChronoLocalDateTime[_]]), + suggestion("Currency", Typed[Currency]), + suggestion("LocalDate", Typed[LocalDate]), + suggestion("LocalTime", Typed[LocalTime]), + suggestion("Locale", Typed[Locale]), + suggestion("UUID", Typed[UUID]), + suggestion("ZoneId", Typed[ZoneId]), + suggestion("ZoneOffset", Typed[ZoneOffset]), ) } @@ -815,6 +828,17 @@ class ExpressionSuggesterSpec suggestion("Integer", Typed[java.lang.Integer]), suggestion("Short", Typed[java.lang.Short]), suggestion("Byte", Typed[java.lang.Byte]), + suggestion("Charset", Typed[Charset]), + suggestion("ChronoLocalDate", Typed[ChronoLocalDate]), + suggestion("ChronoLocalDateTime", Typed[ChronoLocalDateTime[_]]), + suggestion("Currency", Typed[Currency]), + suggestion("LocalDate", Typed[LocalDate]), + suggestion("LocalDateTime", Typed[LocalDateTime]), + suggestion("LocalTime", Typed[LocalTime]), + suggestion("Locale", Typed[Locale]), + suggestion("UUID", Typed[UUID]), + suggestion("ZoneId", Typed[ZoneId]), + suggestion("ZoneOffset", Typed[ZoneOffset]), ) } diff --git a/docs/Changelog.md b/docs/Changelog.md index 80992227237..ed3eace7557 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -85,13 +85,13 @@ * [#7021](https://github.com/TouK/nussknacker/pull/7021) Definitions service can return definition without UI config * [#7010](https://github.com/TouK/nussknacker/pull/7010) Dynamic access allowed via indexer operator (`[]`) on expressions typed as `Unknown` * [#7063](https://github.com/TouK/nussknacker/pull/7063) Introduce conversion extension methods in SpeL: - * is(className)/to(className)/toOrNull(className) - * isBoolean/toBoolean/toBooleanOrNull - * isLong/toLong/toLongOrNull - * isDouble/toDouble/toDoubleOrNull - * isBigDecimal/toBigDecimal/toBigDecimalOrNull - * isList/toList/toListOrNull - * isMap/toMap/toMapOrNull - the list of key-value pairs or unknown map can be converted to a map. + * canBe(className)/to(className)/toOrNull(className) + * canBeBoolean/toBoolean/toBooleanOrNull + * canBeLong/toLong/toLongOrNull + * canBeDouble/toDouble/toDoubleOrNull + * canBeBigDecimal/toBigDecimal/toBigDecimalOrNull + * canBeList/toList/toListOrNull + * canBeMap/toMap/toMapOrNull - the list of key-value pairs or unknown map can be converted to a map. * [#7106](https://github.com/TouK/nussknacker/pull/7106) Fix an issue where pressing the “Esc” key did not remove focus from input fields in dialogs, which prevented the dialog window from closing * [#7002](https://github.com/TouK/nussknacker/pull/7002) Resolve an issue with union nodes output expression when nodes were copied and pasted * [#6994](https://github.com/TouK/nussknacker/pull/6994) Fix styling issues for form checkboxes in Firefox diff --git a/engine/flink/management/dev-model/src/test/resources/extractedTypes/devCreator.json b/engine/flink/management/dev-model/src/test/resources/extractedTypes/devCreator.json index d2bc33f57b5..bd5bc831a52 100644 --- a/engine/flink/management/dev-model/src/test/resources/extractedTypes/devCreator.json +++ b/engine/flink/management/dev-model/src/test/resources/extractedTypes/devCreator.json @@ -12,6 +12,44 @@ "refClazzName": "[Ljava.lang.Object;" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeList": [ + { + "description": "Check whether can be convert to a list", + "name": "canBeList", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -80,20 +118,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -103,30 +127,6 @@ } } ], - "isList": [ - { - "description": "Check whether can be convert to a list", - "name": "isList", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "lastIndexOf": [ { "name": "lastIndexOf", @@ -943,6 +943,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -990,50 +1034,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -1311,21 +1311,10 @@ { "clazzName": {"refClazzName": "java.lang.CharSequence"}, "methods": { - "charAt": [ - { - "name": "charAt", - "signature": { - "noVarArgs": [ - {"name": "arg0", "refClazz": {"refClazzName": "java.lang.Integer"}} - ], - "result": {"refClazzName": "java.lang.Character"} - } - } - ], - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -1336,6 +1325,17 @@ ] } ], + "charAt": [ + { + "name": "charAt", + "signature": { + "noVarArgs": [ + {"name": "arg0", "refClazz": {"refClazzName": "java.lang.Integer"}} + ], + "result": {"refClazzName": "java.lang.Character"} + } + } + ], "length": [ { "name": "length", @@ -1433,6 +1433,40 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -1489,30 +1523,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isInfinite": [ { "name": "isInfinite", @@ -1522,16 +1532,6 @@ } } ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isNaN": [ { "name": "isNaN", @@ -1918,6 +1918,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -1974,40 +2018,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isInfinite": [ { "name": "isInfinite", @@ -2017,16 +2027,6 @@ } } ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isNaN": [ { "name": "isNaN", @@ -2433,6 +2433,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -2480,50 +2524,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -3101,6 +3101,40 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -3148,40 +3182,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -3728,74 +3728,74 @@ } } ], - "doubleValue": [ + "canBe": [ { - "name": "doubleValue", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Double"} - } + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] } ], - "floatValue": [ + "canBeBigDecimal": [ { - "name": "floatValue", + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Float"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "intValue": [ + "canBeDouble": [ { - "name": "intValue", + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Integer"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "is": [ + "canBeLong": [ { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } } ], - "isBigDecimal": [ + "doubleValue": [ { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", + "name": "doubleValue", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} + "result": {"refClazzName": "java.lang.Double"} } } ], - "isDouble": [ + "floatValue": [ { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", + "name": "floatValue", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} + "result": {"refClazzName": "java.lang.Float"} } } ], - "isLong": [ + "intValue": [ { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", + "name": "intValue", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} + "result": {"refClazzName": "java.lang.Integer"} } } ], @@ -3920,10 +3920,10 @@ { "clazzName": {"type": "Unknown"}, "methods": { - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -3934,40 +3934,40 @@ ] } ], - "isBigDecimal": [ + "canBeBigDecimal": [ { "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", + "name": "canBeBigDecimal", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isBoolean": [ + "canBeBoolean": [ { "description": "Check whether the value can be convert to a Boolean", - "name": "isBoolean", + "name": "canBeBoolean", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isDouble": [ + "canBeDouble": [ { "description": "Check whether the value can be convert to a Double", - "name": "isDouble", + "name": "canBeDouble", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isList": [ + "canBeList": [ { "description": "Check whether can be convert to a list", - "name": "isList", + "name": "canBeList", "signatures": [ { "noVarArgs": [], @@ -3976,20 +3976,20 @@ ] } ], - "isLong": [ + "canBeLong": [ { "description": "Check whether the value can be convert to a Long", - "name": "isLong", + "name": "canBeLong", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isMap": [ + "canBeMap": [ { "description": "Check whether can be convert to a map", - "name": "isMap", + "name": "canBeMap", "signatures": [ { "noVarArgs": [], @@ -4230,6 +4230,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -4277,50 +4321,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -4618,6 +4618,60 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeBoolean": [ + { + "description": "Check whether the value can be convert to a Boolean", + "name": "canBeBoolean", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "charAt": [ { "name": "charAt", @@ -4753,30 +4807,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isBlank": [ { "name": "isBlank", @@ -4786,26 +4816,6 @@ } } ], - "isBoolean": [ - { - "description": "Check whether the value can be convert to a Boolean", - "name": "isBoolean", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isEmpty": [ { "name": "isEmpty", @@ -4815,16 +4825,6 @@ } } ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "lastIndexOf": [ { "name": "lastIndexOf", @@ -5325,6 +5325,40 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -5506,40 +5540,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -6158,30 +6158,74 @@ } } ], - "bitLength": [ + "bitLength": [ + { + "name": "bitLength", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Integer"} + } + } + ], + "byteValue": [ + { + "name": "byteValue", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Byte"} + } + } + ], + "byteValueExact": [ + { + "name": "byteValueExact", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Byte"} + } + } + ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ { - "name": "bitLength", + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Integer"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "byteValue": [ + "canBeDouble": [ { - "name": "byteValue", + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Byte"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "byteValueExact": [ + "canBeLong": [ { - "name": "byteValueExact", + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Byte"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], @@ -6315,50 +6359,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isProbablePrime": [ { "name": "isProbablePrime", @@ -11665,6 +11665,20 @@ { "clazzName": {"refClazzName": "java.time.ZoneId"}, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "getDisplayName": [ { "name": "getDisplayName", @@ -11695,20 +11709,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "normalized": [ { "name": "normalized", @@ -13030,10 +13030,10 @@ { "clazzName": {"refClazzName": "java.time.temporal.Temporal"}, "methods": { - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -13097,6 +13097,44 @@ "refClazzName": "java.util.Collection" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeList": [ + { + "description": "Check whether can be convert to a list", + "name": "canBeList", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -13141,20 +13179,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -13164,30 +13188,6 @@ } } ], - "isList": [ - { - "description": "Check whether can be convert to a list", - "name": "isList", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "size": [ { "name": "size", @@ -13375,6 +13375,32 @@ "refClazzName": "java.util.List" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -13443,20 +13469,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -13466,18 +13478,6 @@ } } ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "lastIndexOf": [ { "name": "lastIndexOf", @@ -13823,6 +13823,44 @@ "refClazzName": "java.util.Set" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeList": [ + { + "description": "Check whether can be convert to a list", + "name": "canBeList", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -13867,20 +13905,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -13890,30 +13914,6 @@ } } ], - "isList": [ - { - "description": "Check whether can be convert to a list", - "name": "isList", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "size": [ { "name": "size", diff --git a/engine/flink/tests/src/test/resources/extractedTypes/defaultModel.json b/engine/flink/tests/src/test/resources/extractedTypes/defaultModel.json index 36d8c9a239b..7e66bbf952c 100644 --- a/engine/flink/tests/src/test/resources/extractedTypes/defaultModel.json +++ b/engine/flink/tests/src/test/resources/extractedTypes/defaultModel.json @@ -12,6 +12,44 @@ "refClazzName": "[Ljava.lang.Object;" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeList": [ + { + "description": "Check whether can be convert to a list", + "name": "canBeList", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -80,20 +118,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -103,30 +127,6 @@ } } ], - "isList": [ - { - "description": "Check whether can be convert to a list", - "name": "isList", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "lastIndexOf": [ { "name": "lastIndexOf", @@ -463,6 +463,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -510,50 +554,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -831,21 +831,10 @@ { "clazzName": {"refClazzName": "java.lang.CharSequence"}, "methods": { - "charAt": [ - { - "name": "charAt", - "signature": { - "noVarArgs": [ - {"name": "arg0", "refClazz": {"refClazzName": "java.lang.Integer"}} - ], - "result": {"refClazzName": "java.lang.Character"} - } - } - ], - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -856,6 +845,17 @@ ] } ], + "charAt": [ + { + "name": "charAt", + "signature": { + "noVarArgs": [ + {"name": "arg0", "refClazz": {"refClazzName": "java.lang.Integer"}} + ], + "result": {"refClazzName": "java.lang.Character"} + } + } + ], "length": [ { "name": "length", @@ -954,10 +954,10 @@ "refClazzName": "java.lang.Comparable" }, "methods": { - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -1020,6 +1020,40 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -1076,30 +1110,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isInfinite": [ { "name": "isInfinite", @@ -1109,16 +1119,6 @@ } } ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isNaN": [ { "name": "isNaN", @@ -1505,6 +1505,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -1561,40 +1605,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isInfinite": [ { "name": "isInfinite", @@ -1604,16 +1614,6 @@ } } ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isNaN": [ { "name": "isNaN", @@ -2020,6 +2020,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -2067,50 +2111,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -2688,6 +2688,40 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -2735,40 +2769,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -3315,74 +3315,74 @@ } } ], - "doubleValue": [ + "canBe": [ { - "name": "doubleValue", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Double"} - } + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] } ], - "floatValue": [ + "canBeBigDecimal": [ { - "name": "floatValue", + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Float"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "intValue": [ + "canBeDouble": [ { - "name": "intValue", + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Integer"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "is": [ + "canBeLong": [ { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } } ], - "isBigDecimal": [ + "doubleValue": [ { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", + "name": "doubleValue", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} + "result": {"refClazzName": "java.lang.Double"} } } ], - "isDouble": [ + "floatValue": [ { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", + "name": "floatValue", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} + "result": {"refClazzName": "java.lang.Float"} } } ], - "isLong": [ + "intValue": [ { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", + "name": "intValue", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} + "result": {"refClazzName": "java.lang.Integer"} } } ], @@ -3507,10 +3507,10 @@ { "clazzName": {"type": "Unknown"}, "methods": { - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -3521,40 +3521,40 @@ ] } ], - "isBigDecimal": [ + "canBeBigDecimal": [ { "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", + "name": "canBeBigDecimal", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isBoolean": [ + "canBeBoolean": [ { "description": "Check whether the value can be convert to a Boolean", - "name": "isBoolean", + "name": "canBeBoolean", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isDouble": [ + "canBeDouble": [ { "description": "Check whether the value can be convert to a Double", - "name": "isDouble", + "name": "canBeDouble", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isList": [ + "canBeList": [ { "description": "Check whether can be convert to a list", - "name": "isList", + "name": "canBeList", "signatures": [ { "noVarArgs": [], @@ -3563,20 +3563,20 @@ ] } ], - "isLong": [ + "canBeLong": [ { "description": "Check whether the value can be convert to a Long", - "name": "isLong", + "name": "canBeLong", "signature": { "noVarArgs": [], "result": {"refClazzName": "java.lang.Boolean"} } } ], - "isMap": [ + "canBeMap": [ { "description": "Check whether can be convert to a map", - "name": "isMap", + "name": "canBeMap", "signatures": [ { "noVarArgs": [], @@ -3817,6 +3817,50 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -3864,50 +3908,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -4205,6 +4205,60 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ + { + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeBoolean": [ + { + "description": "Check whether the value can be convert to a Boolean", + "name": "canBeBoolean", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "charAt": [ { "name": "charAt", @@ -4340,30 +4394,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isBlank": [ { "name": "isBlank", @@ -4373,26 +4403,6 @@ } } ], - "isBoolean": [ - { - "description": "Check whether the value can be convert to a Boolean", - "name": "isBoolean", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isEmpty": [ { "name": "isEmpty", @@ -4402,16 +4412,6 @@ } } ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "lastIndexOf": [ { "name": "lastIndexOf", @@ -4912,6 +4912,40 @@ } } ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeDouble": [ + { + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], + "canBeLong": [ + { + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + } + ], "compareTo": [ { "name": "compareTo", @@ -5093,40 +5127,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "longValue": [ { "name": "longValue", @@ -5745,30 +5745,74 @@ } } ], - "bitLength": [ + "bitLength": [ + { + "name": "bitLength", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Integer"} + } + } + ], + "byteValue": [ + { + "name": "byteValue", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Byte"} + } + } + ], + "byteValueExact": [ + { + "name": "byteValueExact", + "signature": { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Byte"} + } + } + ], + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeBigDecimal": [ { - "name": "bitLength", + "description": "Check whether the value can be convert to a BigDecimal", + "name": "canBeBigDecimal", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Integer"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "byteValue": [ + "canBeDouble": [ { - "name": "byteValue", + "description": "Check whether the value can be convert to a Double", + "name": "canBeDouble", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Byte"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], - "byteValueExact": [ + "canBeLong": [ { - "name": "byteValueExact", + "description": "Check whether the value can be convert to a Long", + "name": "canBeLong", "signature": { "noVarArgs": [], - "result": {"refClazzName": "java.lang.Byte"} + "result": {"refClazzName": "java.lang.Boolean"} } } ], @@ -5902,50 +5946,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isBigDecimal": [ - { - "description": "Check whether the value can be convert to a BigDecimal", - "name": "isBigDecimal", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isDouble": [ - { - "description": "Check whether the value can be convert to a Double", - "name": "isDouble", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], - "isLong": [ - { - "description": "Check whether the value can be convert to a Long", - "name": "isLong", - "signature": { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - } - ], "isProbablePrime": [ { "name": "isProbablePrime", @@ -11267,6 +11267,20 @@ { "clazzName": {"refClazzName": "java.time.ZoneId"}, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "getDisplayName": [ { "name": "getDisplayName", @@ -11297,20 +11311,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "normalized": [ { "name": "normalized", @@ -13350,10 +13350,10 @@ { "clazzName": {"refClazzName": "java.time.temporal.Temporal"}, "methods": { - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -13407,10 +13407,10 @@ { "clazzName": {"refClazzName": "java.time.temporal.TemporalAccessor"}, "methods": { - "is": [ + "canBe": [ { "description": "Checks if a type can be converted to a given class", - "name": "is", + "name": "canBe", "signatures": [ { "noVarArgs": [ @@ -13474,6 +13474,44 @@ "refClazzName": "java.util.Collection" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeList": [ + { + "description": "Check whether can be convert to a list", + "name": "canBeList", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -13518,20 +13556,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -13541,30 +13565,6 @@ } } ], - "isList": [ - { - "description": "Check whether can be convert to a list", - "name": "isList", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "size": [ { "name": "size", @@ -13752,6 +13752,32 @@ "refClazzName": "java.util.List" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -13820,20 +13846,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -13843,18 +13855,6 @@ } } ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "lastIndexOf": [ { "name": "lastIndexOf", @@ -14215,6 +14215,44 @@ "refClazzName": "java.util.Set" }, "methods": { + "canBe": [ + { + "description": "Checks if a type can be converted to a given class", + "name": "canBe", + "signatures": [ + { + "noVarArgs": [ + {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} + ], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeList": [ + { + "description": "Check whether can be convert to a list", + "name": "canBeList", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], + "canBeMap": [ + { + "description": "Check whether can be convert to a map", + "name": "canBeMap", + "signatures": [ + { + "noVarArgs": [], + "result": {"refClazzName": "java.lang.Boolean"} + } + ] + } + ], "contains": [ { "name": "contains", @@ -14259,20 +14297,6 @@ } } ], - "is": [ - { - "description": "Checks if a type can be converted to a given class", - "name": "is", - "signatures": [ - { - "noVarArgs": [ - {"name": "className", "refClazz": {"refClazzName": "java.lang.String"}} - ], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "isEmpty": [ { "name": "isEmpty", @@ -14282,30 +14306,6 @@ } } ], - "isList": [ - { - "description": "Check whether can be convert to a list", - "name": "isList", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], - "isMap": [ - { - "description": "Check whether can be convert to a map", - "name": "isMap", - "signatures": [ - { - "noVarArgs": [], - "result": {"refClazzName": "java.lang.Boolean"} - } - ] - } - ], "size": [ { "name": "size", diff --git a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/CastOrConversionExt.scala b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/CastOrConversionExt.scala index 5bcb3673e7b..e2264e67e9d 100644 --- a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/CastOrConversionExt.scala +++ b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/CastOrConversionExt.scala @@ -2,16 +2,27 @@ package pl.touk.nussknacker.engine.extension import cats.data.ValidatedNel import cats.implicits.catsSyntaxValidatedId +import org.apache.commons.lang3.LocaleUtils +import org.springframework.util.StringUtils import pl.touk.nussknacker.engine.api.generics.{GenericFunctionTypingError, MethodTypeInfo, Parameter} import pl.touk.nussknacker.engine.api.typed.typing import pl.touk.nussknacker.engine.api.typed.typing.{Typed, TypedObjectWithValue, TypingResult, Unknown} import pl.touk.nussknacker.engine.definition.clazz.{ClassDefinitionSet, FunctionalMethodDefinition, MethodDefinition} -import pl.touk.nussknacker.engine.extension.CastOrConversionExt.getConversion +import pl.touk.nussknacker.engine.extension.CastOrConversionExt.{ + canBeMethodName, + getConversion, + toMethodName, + toOrNullMethodName +} import pl.touk.nussknacker.engine.extension.ExtensionMethod.SingleArg import pl.touk.nussknacker.engine.util.Implicits.RichScalaMap import pl.touk.nussknacker.engine.util.classes.Extensions.{ClassExtensions, ClassesExtensions} import java.lang.{Boolean => JBoolean} +import java.nio.charset.Charset +import java.time.chrono.{ChronoLocalDate, ChronoLocalDateTime} +import java.time.{LocalDate, LocalDateTime, LocalTime, ZoneId, ZoneOffset} +import java.util.{Currency, UUID} import scala.util.Try // todo: lbg - add casting methods to UTIL @@ -19,12 +30,12 @@ class CastOrConversionExt(classesBySimpleName: Map[String, Class[_]]) { private val castException = new ClassCastException(s"Cannot cast value to given class") private val methodRegistry: Map[String, ExtensionMethod[_]] = Map( - "is" -> SingleArg(is), - "to" -> SingleArg(to), - "toOrNull" -> SingleArg(toOrNull), + canBeMethodName -> SingleArg(canBe), + toMethodName -> SingleArg(to), + toOrNullMethodName -> SingleArg(toOrNull), ) - private def is(target: Any, className: String): Boolean = + private def canBe(target: Any, className: String): Boolean = getClass(className).exists(clazz => clazz.isAssignableFrom(target.getClass)) || getConversion(className).exists(_.canConvert(target)) @@ -60,11 +71,12 @@ class CastOrConversionExt(classesBySimpleName: Map[String, Class[_]]) { } object CastOrConversionExt extends ExtensionMethodsDefinition { - private[extension] val isMethodName = "is" - private[extension] val toMethodName = "to" - private[extension] val toOrNullMethodName = "toOrNull" - private val castOrConversionMethods = Set(isMethodName, toMethodName, toOrNullMethodName) private val stringClass = classOf[String] + private[extension] val canBeMethodName = "canBe" + private[extension] val toMethodName = "to" + private[extension] val orNullSuffix = "OrNull" + private[extension] val toOrNullMethodName = toMethodName + orNullSuffix + private val castOrConversionMethods = Set(canBeMethodName, toMethodName, toOrNullMethodName) private val conversionsRegistry: List[Conversion[_ >: Null <: AnyRef]] = List( ToLongConversion, @@ -79,6 +91,23 @@ object CastOrConversionExt extends ExtensionMethodsDefinition { ToIntegerConversion, ToFloatConversion, ToBigIntegerConversion, + new FromStringConversion(ZoneOffset.of), + new FromStringConversion(ZoneId.of), + new FromStringConversion((source: String) => { + val locale = StringUtils.parseLocale(source) + assert(LocaleUtils.isAvailableLocale(locale)) // without this check even "qwerty" is considered a Locale + locale + }), + new FromStringConversion(Charset.forName), + new FromStringConversion(Currency.getInstance), + new FromStringConversion[UUID]((source: String) => + if (StringUtils.hasLength(source)) UUID.fromString(source.trim) else null + ), + new FromStringConversion(LocalTime.parse), + new FromStringConversion(LocalDate.parse), + new FromStringConversion(LocalDateTime.parse), + new FromStringConversion[ChronoLocalDate](LocalDate.parse), + new FromStringConversion[ChronoLocalDateTime[_]](LocalDateTime.parse) ) private val conversionsByType: Map[String, Conversion[_ >: Null <: AnyRef]] = conversionsRegistry @@ -124,19 +153,19 @@ object CastOrConversionExt extends ExtensionMethodsDefinition { FunctionalMethodDefinition( (target, params) => canConvertToTyping(allowedClasses)(target, params), methodTypeInfoWithStringParam(Typed.typedClass[JBoolean]), - "is", + canBeMethodName, Some("Checks if a type can be converted to a given class") ), FunctionalMethodDefinition( (target, params) => convertToTyping(allowedClasses)(target, params), methodTypeInfoWithStringParam(Unknown), - "to", + toMethodName, Some("Converts a type to a given class or throws exception if type cannot be converted.") ), FunctionalMethodDefinition( (target, params) => convertToTyping(allowedClasses)(target, params), methodTypeInfoWithStringParam(Unknown), - "toOrNull", + toOrNullMethodName, Some("Converts a type to a given class or return null if type cannot be converted.") ), ).groupBy(_.name) diff --git a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/Conversion.scala b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/Conversion.scala index 1b70c96140e..b5200171f46 100644 --- a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/Conversion.scala +++ b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/Conversion.scala @@ -23,6 +23,10 @@ import scala.reflect.{ClassTag, classTag} import scala.util.{Success, Try} abstract class Conversion[T >: Null <: AnyRef: ClassTag] { + private[extension] val numberClass = classOf[JNumber] + private[extension] val stringClass = classOf[String] + private[extension] val unknownClass = classOf[Object] + val resultTypeClass: Class[T] = classTag[T].runtimeClass.asInstanceOf[Class[T]] val typingResult: TypingResult = Typed.typedClass(resultTypeClass) val typingFunction: TypingResult => ValidatedNel[GenericFunctionTypingError, TypingResult] = @@ -34,10 +38,6 @@ abstract class Conversion[T >: Null <: AnyRef: ClassTag] { } abstract class ToNumericConversion[T >: Null <: AnyRef: ClassTag] extends Conversion[T] { - private val numberClass = classOf[JNumber] - private val stringClass = classOf[String] - private val unknownClass = classOf[Object] - override def appliesToConversion(clazz: Class[_]): Boolean = clazz != resultTypeClass && (clazz.isAOrChildOf(numberClass) || clazz == stringClass || clazz == unknownClass) @@ -80,7 +80,7 @@ object ToBigDecimalConversion extends ToNumericConversion[JBigDecimal] { object ToBooleanConversion extends Conversion[JBoolean] { private val cannotConvertException = (value: Any) => new IllegalArgumentException(s"Cannot convert: $value to Boolean") - private val allowedClassesForConversion: Set[Class[_]] = Set(classOf[String], classOf[Object]) + private val allowedClassesForConversion: Set[Class[_]] = Set(stringClass, unknownClass) override def appliesToConversion(clazz: Class[_]): Boolean = allowedClassesForConversion.contains(clazz) @@ -126,12 +126,11 @@ object ToLongConversion extends ToNumericConversion[JLong] { } object ToStringConversion extends Conversion[String] { - override def appliesToConversion(clazz: Class[_]): Boolean = clazz == classOf[Object] + override def appliesToConversion(clazz: Class[_]): Boolean = clazz == unknownClass override def convertEither(value: Any): Either[Throwable, String] = Right(value.toString) } abstract class ToCollectionConversion[T >: Null <: AnyRef: ClassTag] extends Conversion[T] { - private val unknownClass = classOf[Object] private val collectionClass = classOf[JCollection[_]] override def appliesToConversion(clazz: Class[_]): Boolean = @@ -193,3 +192,8 @@ object ToBigIntegerConversion extends ToNumericConversion[JBigInteger] { } } + +final class FromStringConversion[T >: Null <: AnyRef: ClassTag](convert: String => T) extends Conversion[T] { + override def convertEither(value: Any): Either[Throwable, T] = Try(convert(value.asInstanceOf[String])).toEither + override def appliesToConversion(clazz: Class[_]): Boolean = clazz == stringClass || clazz == unknownClass +} diff --git a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ConversionExt.scala b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ConversionExt.scala index 6f552324763..6ece61c5791 100644 --- a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ConversionExt.scala +++ b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ConversionExt.scala @@ -11,12 +11,12 @@ import java.lang.{Boolean => JBoolean} class ConversionExt(conversion: Conversion[_]) extends ExtensionMethodsDefinition { private lazy val definitionsByName = definitions().groupBy(_.name) + private lazy val targetTypeName = conversion.resultTypeClass.simpleName() - private lazy val targetTypeName = conversion.resultTypeClass.simpleName() - - private val isMethodName = s"is$targetTypeName" - private val toMethodName = s"to$targetTypeName" - private val toOrNullMethodName = s"to${targetTypeName}OrNull" + private val canBeMethodName = s"${CastOrConversionExt.canBeMethodName}$targetTypeName" + private val toMethodName = s"${CastOrConversionExt.toMethodName}$targetTypeName" + private val toOrNullMethodName = + s"${CastOrConversionExt.toMethodName}${targetTypeName}${CastOrConversionExt.orNullSuffix}" // Convert methods should visible in runtime for every class because we allow invoke convert methods on an unknown // object in Typer, but in the runtime the same type could be known and that's why should add convert method to an @@ -34,7 +34,7 @@ class ConversionExt(conversion: Conversion[_]) extends ExtensionMethodsDefinitio } yield resultMethod private def mapMethodName(methodName: String): Option[String] = methodName match { - case `isMethodName` => Some(CastOrConversionExt.isMethodName) + case `canBeMethodName` => Some(CastOrConversionExt.canBeMethodName) case `toMethodName` => Some(CastOrConversionExt.toMethodName) case `toOrNullMethodName` => Some(CastOrConversionExt.toOrNullMethodName) case _ => None @@ -49,22 +49,21 @@ class ConversionExt(conversion: Conversion[_]) extends ExtensionMethodsDefinitio } protected def definitions(): List[MethodDefinition] = { - val targetTypeSimpleName = conversion.resultTypeClass.simpleName() List( definition( Typed.typedClass[JBoolean], - s"is$targetTypeSimpleName", - Some(s"Check whether the value can be convert to a $targetTypeSimpleName") + canBeMethodName, + Some(s"Check whether the value can be convert to a $targetTypeName") ), definition( conversion.typingResult, - s"to$targetTypeSimpleName", - Some(s"Convert the value to $targetTypeSimpleName or throw exception in case of failure") + toMethodName, + Some(s"Convert the value to $targetTypeName or throw exception in case of failure") ), definition( conversion.typingResult, - s"to${targetTypeSimpleName}OrNull", - Some(s"Convert the value to $targetTypeSimpleName or null in case of failure") + toOrNullMethodName, + Some(s"Convert the value to $targetTypeName or null in case of failure") ), ) } diff --git a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToListConversionExt.scala b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToListConversionExt.scala index 08373dfe1e7..d77e2b1f371 100644 --- a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToListConversionExt.scala +++ b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToListConversionExt.scala @@ -5,6 +5,7 @@ import cats.implicits.catsSyntaxValidatedId import pl.touk.nussknacker.engine.api.generics.{GenericFunctionTypingError, MethodTypeInfo} import pl.touk.nussknacker.engine.api.typed.typing.{Typed, TypedClass, TypingResult, Unknown} import pl.touk.nussknacker.engine.definition.clazz.{FunctionalMethodDefinition, MethodDefinition} +import pl.touk.nussknacker.engine.extension.CastOrConversionExt.{canBeMethodName, orNullSuffix, toMethodName} import pl.touk.nussknacker.engine.spel.internal.ConversionHandler import pl.touk.nussknacker.engine.util.classes.Extensions.ClassExtensions @@ -19,21 +20,21 @@ object ToListConversionExt extends ConversionExt(ToListConversion) { private val isListMethodDefinition = FunctionalMethodDefinition( typeFunction = (targetTyping, _) => ToListConversion.typingFunction(targetTyping).map(_ => booleanTyping), signature = MethodTypeInfo.noArgTypeInfo(booleanTyping), - name = "isList", + name = s"${canBeMethodName}List", description = Some("Check whether can be convert to a list") ) private val toListDefinition = FunctionalMethodDefinition( typeFunction = (invocationTarget, _) => ToListConversion.typingFunction(invocationTarget), signature = MethodTypeInfo.noArgTypeInfo(listTyping), - name = "toList", + name = s"${toMethodName}List", description = Option("Convert to a list or throw exception in case of failure") ) private val toListOrNullDefinition = FunctionalMethodDefinition( typeFunction = (invocationTarget, _) => ToListConversion.typingFunction(invocationTarget), signature = MethodTypeInfo.noArgTypeInfo(listTyping), - name = "toListOrNull", + name = s"${toMethodName}List${orNullSuffix}", description = Option("Convert to a list or null in case of failure") ) diff --git a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToMapConversionExt.scala b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToMapConversionExt.scala index 9a83e72ea38..632c206357b 100644 --- a/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToMapConversionExt.scala +++ b/scenario-compiler/src/main/scala/pl/touk/nussknacker/engine/extension/ToMapConversionExt.scala @@ -5,6 +5,7 @@ import cats.implicits.catsSyntaxValidatedId import pl.touk.nussknacker.engine.api.generics.{GenericFunctionTypingError, MethodTypeInfo} import pl.touk.nussknacker.engine.api.typed.typing._ import pl.touk.nussknacker.engine.definition.clazz.{FunctionalMethodDefinition, MethodDefinition} +import pl.touk.nussknacker.engine.extension.CastOrConversionExt.{canBeMethodName, orNullSuffix, toMethodName} import pl.touk.nussknacker.engine.spel.internal.ConversionHandler import java.lang.{Boolean => JBoolean} @@ -18,21 +19,21 @@ object ToMapConversionExt extends ConversionExt(ToMapConversion) { private val isMapMethodDefinition = FunctionalMethodDefinition( typeFunction = (invocationTarget, _) => ToMapConversion.typingFunction(invocationTarget).map(_ => booleanTyping), signature = MethodTypeInfo.noArgTypeInfo(booleanTyping), - name = "isMap", + name = s"${canBeMethodName}Map", description = Some("Check whether can be convert to a map") ) private val toMapDefinition = FunctionalMethodDefinition( typeFunction = (invocationTarget, _) => ToMapConversion.typingFunction(invocationTarget), signature = MethodTypeInfo.noArgTypeInfo(mapTyping), - name = "toMap", + name = s"${toMethodName}Map", description = Option("Convert to a map or throw exception in case of failure") ) private val toMapOrNullDefinition = FunctionalMethodDefinition( typeFunction = (invocationTarget, _) => ToMapConversion.typingFunction(invocationTarget), signature = MethodTypeInfo.noArgTypeInfo(mapTyping), - name = "toMapOrNull", + name = s"${toMethodName}Map${orNullSuffix}", description = Option("Convert to a map or null in case of failure") ) diff --git a/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/extension/ExtensionMethodsSpec.scala b/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/extension/ExtensionMethodsSpec.scala index b8e8c015efb..f8d4c65985b 100644 --- a/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/extension/ExtensionMethodsSpec.scala +++ b/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/extension/ExtensionMethodsSpec.scala @@ -34,44 +34,44 @@ class ExtensionMethodsSpec extends AnyFunSuite with Matchers { .classDefinitionsMap .map(e => e._1.getName -> e._2.methods.keys) shouldBe Map( "java.lang.String" -> Set( - "isBigDecimal", + "canBeBigDecimal", "toBigDecimal", "toBigDecimalOrNull", - "isBoolean", + "canBeBoolean", "toBoolean", "toBooleanOrNull", - "isDouble", + "canBeDouble", "toDouble", "toDoubleOrNull", - "isLong", + "canBeLong", "toLong", "toLongOrNull", "toUpperCase", - "is", + "canBe", "to", "toOrNull", ), "java.lang.Object" -> Set( - "isBigDecimal", + "canBeBigDecimal", "toBigDecimal", "toBigDecimalOrNull", - "isBoolean", + "canBeBoolean", "toBoolean", "toBooleanOrNull", - "isDouble", + "canBeDouble", "toDouble", "toDoubleOrNull", - "isLong", + "canBeLong", "toLong", "toLongOrNull", "toString", - "is", + "canBe", "to", "toOrNull", - "isMap", + "canBeMap", "toMap", "toMapOrNull", - "isList", + "canBeList", "toList", "toListOrNull" ), diff --git a/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/spel/SpelExpressionSpec.scala b/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/spel/SpelExpressionSpec.scala index db93027d6d5..b446d5334d2 100644 --- a/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/spel/SpelExpressionSpec.scala +++ b/scenario-compiler/src/test/scala/pl/touk/nussknacker/engine/spel/SpelExpressionSpec.scala @@ -12,7 +12,7 @@ import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers import org.scalatest.prop.TableDrivenPropertyChecks._ import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import org.springframework.util.NumberUtils +import org.springframework.util.{NumberUtils, StringUtils} import pl.touk.nussknacker.engine.api.context.ValidationContext import pl.touk.nussknacker.engine.api.dict.embedded.EmbeddedDictDefinition import pl.touk.nussknacker.engine.api.dict.{DictDefinition, DictInstance} @@ -63,9 +63,9 @@ import java.lang.{ Short => JShort } import java.math.{BigDecimal => JBigDecimal, BigInteger => JBigInteger} -import java.nio.charset.Charset -import java.time.chrono.ChronoLocalDate -import java.time.{LocalDate, LocalDateTime} +import java.nio.charset.{Charset, StandardCharsets} +import java.time.chrono.{ChronoLocalDate, ChronoLocalDateTime} +import java.time.{LocalDate, LocalDateTime, LocalTime, ZoneId, ZoneOffset} import java.util import java.util.{Collections, Currency, List => JList, Locale, Map => JMap, Optional, UUID} import scala.annotation.varargs @@ -1491,8 +1491,8 @@ class SpelExpressionSpec extends AnyFunSuite with Matchers with ValidatedValuesD forAll( Table( ("expression", "expectedResult"), - ("#unknownString.value.is('java.lang.String')", true), - ("#unknownString.value.is('java.lang.Integer')", false), + ("#unknownString.value.canBe('java.lang.String')", true), + ("#unknownString.value.canBe('java.lang.Integer')", false), ) ) { (expression, expectedResult) => evaluate[Any](expression) shouldBe expectedResult @@ -1590,7 +1590,7 @@ class SpelExpressionSpec extends AnyFunSuite with Matchers with ValidatedValuesD test("should allow invoke conversion methods with class simple names") { evaluate[Any]( - "{#unknownLong.value.toOrNull('Long'), #unknownLong.value.to('Long'), #unknownLong.value.is('Long')}", + "{#unknownLong.value.toOrNull('Long'), #unknownLong.value.to('Long'), #unknownLong.value.canBe('Long')}", ctx.withVariable("unknownLong", ContainerOfUnknown(11L)) ) shouldBe List(11L, 11L, true).asJava } @@ -1654,6 +1654,15 @@ class SpelExpressionSpec extends AnyFunSuite with Matchers with ValidatedValuesD val emptyList = List().asJava val emptyTuplesList = List(Map().asJava).asJava val convertedDoubleToBigDecimal = NumberUtils.convertNumberToTargetClass(1.1, classOf[JBigDecimal]) + val zoneOffset = ZoneOffset.of("+01:00") + val zoneId = ZoneId.of("Europe/Warsaw") + val locale = StringUtils.parseLocale("pl_PL") + val charset = StandardCharsets.UTF_8 + val currency = Currency.getInstance("USD") + val uuid = UUID.fromString("7447e433-83dd-47d0-a115-769a03236bca") + val localTime = LocalTime.parse("10:15:30") + val localDate = LocalDate.parse("2024-11-04") + val localDateTime = LocalDateTime.parse("2024-11-04T10:15:30") val customCtx = ctx .withVariable("unknownInteger", ContainerOfUnknown(1)) .withVariable("unknownBoolean", ContainerOfUnknown(false)) @@ -1669,18 +1678,29 @@ class SpelExpressionSpec extends AnyFunSuite with Matchers with ValidatedValuesD .withVariable("unknownListOfTuples", ContainerOfUnknown(listOfTuples)) .withVariable("unknownEmptyList", ContainerOfUnknown(emptyList)) .withVariable("unknownEmptyTuplesList", ContainerOfUnknown(emptyTuplesList)) - val byteTyping = Typed.typedClass[JByte] - val shortTyping = Typed.typedClass[JShort] - val integerTyping = Typed.typedClass[JInteger] - val longTyping = Typed.typedClass[JLong] - val floatTyping = Typed.typedClass[JFloat] - val doubleTyping = Typed.typedClass[JDouble] - val bigDecimalTyping = Typed.typedClass[JBigDecimal] - val bigIntegerTyping = Typed.typedClass[JBigInteger] - val booleanTyping = Typed.typedClass[JBoolean] - val stringTyping = Typed.typedClass[String] - val mapTyping = Typed.genericTypeClass[JMap[_, _]](List(Unknown, Unknown)) - val listTyping = Typed.genericTypeClass[JList[_]](List(Unknown)) + val byteTyping = Typed.typedClass[JByte] + val shortTyping = Typed.typedClass[JShort] + val integerTyping = Typed.typedClass[JInteger] + val longTyping = Typed.typedClass[JLong] + val floatTyping = Typed.typedClass[JFloat] + val doubleTyping = Typed.typedClass[JDouble] + val bigDecimalTyping = Typed.typedClass[JBigDecimal] + val bigIntegerTyping = Typed.typedClass[JBigInteger] + val booleanTyping = Typed.typedClass[JBoolean] + val stringTyping = Typed.typedClass[String] + val mapTyping = Typed.genericTypeClass[JMap[_, _]](List(Unknown, Unknown)) + val listTyping = Typed.genericTypeClass[JList[_]](List(Unknown)) + val zoneOffsetTyping = Typed.typedClass[ZoneOffset] + val zoneIdTyping = Typed.typedClass[ZoneId] + val localeTyping = Typed.typedClass[Locale] + val charsetTyping = Typed.typedClass[Charset] + val currencyTyping = Typed.typedClass[Currency] + val uuidTyping = Typed.typedClass[UUID] + val localTimeTyping = Typed.typedClass[LocalTime] + val localDateTyping = Typed.typedClass[LocalDate] + val localDateTimeTyping = Typed.typedClass[LocalDateTime] + val chronoLocalDateTyping = Typed.typedClass[ChronoLocalDate] + val chronoLocalDateTimeTyping = Typed.typedClass[ChronoLocalDateTime[_]] forAll( Table( ("expression", "expectedType", "expectedResult"), @@ -1747,6 +1767,17 @@ class SpelExpressionSpec extends AnyFunSuite with Matchers with ValidatedValuesD ("'1'.to('BigInteger')", bigIntegerTyping, JBigInteger.ONE), ("1.toOrNull('BigInteger')", bigIntegerTyping, JBigInteger.ONE), ("'1'.toOrNull('BigInteger')", bigIntegerTyping, JBigInteger.ONE), + ("'+01:00'.to('ZoneOffset')", zoneOffsetTyping, zoneOffset), + ("'Europe/Warsaw'.to('ZoneId')", zoneIdTyping, zoneId), + ("'pl_PL'.to('Locale')", localeTyping, locale), + ("'UTF-8'.to('Charset')", charsetTyping, charset), + ("'USD'.to('Currency')", currencyTyping, currency), + ("'7447e433-83dd-47d0-a115-769a03236bca'.to('UUID')", uuidTyping, uuid), + ("'10:15:30'.to('LocalTime')", localTimeTyping, localTime), + ("'2024-11-04'.to('LocalDate')", localDateTyping, localDate), + ("'2024-11-04T10:15:30'.to('LocalDateTime')", localDateTimeTyping, localDateTime), + ("'2024-11-04'.to('ChronoLocalDate')", chronoLocalDateTyping, localDate), + ("'2024-11-04T10:15:30'.to('ChronoLocalDateTime')", chronoLocalDateTimeTyping, localDateTime), ("#unknownString.value.to('String')", stringTyping, "unknown"), ("#unknownMap.value.to('Map')", mapTyping, map), ("#unknownMap.value.toOrNull('Map')", mapTyping, map), @@ -1839,58 +1870,58 @@ class SpelExpressionSpec extends AnyFunSuite with Matchers with ValidatedValuesD forAll( Table( ("expression", "result"), - ("#unknownBoolean.value.is('Boolean')", true), - ("#unknownBooleanString.value.is('Boolean')", true), - ("#unknownString.value.is('Boolean')", false), - ("#unknownLong.value.is('Byte')", true), - ("#unknownLongString.value.is('Byte')", true), - ("#unknownString.value.is('Byte')", false), - ("#unknownLong.value.is('Short')", true), - ("#unknownLongString.value.is('Short')", true), - ("#unknownString.value.is('Short')", false), - ("#unknownLong.value.is('Integer')", true), - ("#unknownLongString.value.is('Integer')", true), - ("#unknownString.value.is('Integer')", false), - ("#unknownLong.value.is('Long')", true), - ("#unknownLongString.value.is('Long')", true), - ("#unknownString.value.is('Long')", false), - ("#unknownLong.value.is('BigInteger')", true), - ("#unknownLongString.value.is('BigInteger')", true), - ("#unknownString.value.is('BigInteger')", false), - ("#unknownDouble.value.is('Double')", true), - ("#unknownDoubleString.value.is('Double')", true), - ("#unknownString.value.is('Double')", false), - ("#unknownDouble.value.is('Float')", true), - ("#unknownDoubleString.value.is('Float')", true), - ("#unknownString.value.is('Float')", false), - ("#unknownBigDecimal.value.is('BigDecimal')", true), - ("#unknownBigDecimalString.value.is('BigDecimal')", true), - ("#unknownString.value.is('BigDecimal')", false), - ("#unknownList.value.is('List')", true), - ("#unknownList.value.is('Map')", false), - ("#unknownMap.value.is('List')", false), - ("#unknownMap.value.is('Map')", true), - ("#unknownListOfTuples.value.is('List')", true), - ("#unknownListOfTuples.value.is('Map')", true), - ("#unknownBoolean.value.isBoolean", true), - ("#unknownBooleanString.value.isBoolean", true), - ("#unknownString.value.isBoolean", false), - ("#unknownLong.value.isLong", true), - ("#unknownLongString.value.isLong", true), - ("#unknownString.value.isLong", false), - ("#unknownDouble.value.isDouble", true), - ("#unknownDoubleString.value.isDouble", true), - ("#unknownString.value.isDouble", false), - ("#unknownBigDecimal.value.isBigDecimal", true), - ("#unknownBigDecimalString.value.isBigDecimal", true), - ("#unknownString.value.isBigDecimal", false), - ("#unknownList.value.isList", true), - ("#unknownList.value.isMap", false), - ("#unknownMap.value.isList", false), - ("#unknownMap.value.isMap", true), - ("#unknownListOfTuples.value.isList", true), - ("#unknownListOfTuples.value.isMap", true), - ("#arrayOfUnknown.isList", true), + ("#unknownBoolean.value.canBe('Boolean')", true), + ("#unknownBooleanString.value.canBe('Boolean')", true), + ("#unknownString.value.canBe('Boolean')", false), + ("#unknownLong.value.canBe('Byte')", true), + ("#unknownLongString.value.canBe('Byte')", true), + ("#unknownString.value.canBe('Byte')", false), + ("#unknownLong.value.canBe('Short')", true), + ("#unknownLongString.value.canBe('Short')", true), + ("#unknownString.value.canBe('Short')", false), + ("#unknownLong.value.canBe('Integer')", true), + ("#unknownLongString.value.canBe('Integer')", true), + ("#unknownString.value.canBe('Integer')", false), + ("#unknownLong.value.canBe('Long')", true), + ("#unknownLongString.value.canBe('Long')", true), + ("#unknownString.value.canBe('Long')", false), + ("#unknownLong.value.canBe('BigInteger')", true), + ("#unknownLongString.value.canBe('BigInteger')", true), + ("#unknownString.value.canBe('BigInteger')", false), + ("#unknownDouble.value.canBe('Double')", true), + ("#unknownDoubleString.value.canBe('Double')", true), + ("#unknownString.value.canBe('Double')", false), + ("#unknownDouble.value.canBe('Float')", true), + ("#unknownDoubleString.value.canBe('Float')", true), + ("#unknownString.value.canBe('Float')", false), + ("#unknownBigDecimal.value.canBe('BigDecimal')", true), + ("#unknownBigDecimalString.value.canBe('BigDecimal')", true), + ("#unknownString.value.canBe('BigDecimal')", false), + ("#unknownList.value.canBe('List')", true), + ("#unknownList.value.canBe('Map')", false), + ("#unknownMap.value.canBe('List')", false), + ("#unknownMap.value.canBe('Map')", true), + ("#unknownListOfTuples.value.canBe('List')", true), + ("#unknownListOfTuples.value.canBe('Map')", true), + ("#unknownBoolean.value.canBeBoolean", true), + ("#unknownBooleanString.value.canBeBoolean", true), + ("#unknownString.value.canBeBoolean", false), + ("#unknownLong.value.canBeLong", true), + ("#unknownLongString.value.canBeLong", true), + ("#unknownString.value.canBeLong", false), + ("#unknownDouble.value.canBeDouble", true), + ("#unknownDoubleString.value.canBeDouble", true), + ("#unknownString.value.canBeDouble", false), + ("#unknownBigDecimal.value.canBeBigDecimal", true), + ("#unknownBigDecimalString.value.canBeBigDecimal", true), + ("#unknownString.value.canBeBigDecimal", false), + ("#unknownList.value.canBeList", true), + ("#unknownList.value.canBeMap", false), + ("#unknownMap.value.canBeList", false), + ("#unknownMap.value.canBeMap", true), + ("#unknownListOfTuples.value.canBeList", true), + ("#unknownListOfTuples.value.canBeMap", true), + ("#arrayOfUnknown.canBeList", true), ) ) { (expression, result) => evaluate[Any](expression, customCtx) shouldBe result