= ScalarMarshaller
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Provides an SPI to allow different scalar datatypes to be marshalled to and from GraphQL scalar types.

The implementations are called following a chain-of-responsibility pattern, first one matching is used. Use _jakarta.annotation.Priority_ (with _org.apache.causeway.applib.annotation.PriorityPrecedence_ values) to override the framework-provided defaults, earliest wins.

== API

[source,java]
.ScalarMarshaller.java
----
interface ScalarMarshaller<K> {
  boolean handles(Class<?> javaClass)     // <.>
  GraphQLScalarType getGqlScalarType()     // <.>
  K unmarshal(Object graphValue, Class<?> targetType)     // <.>
}
----

<.> xref:#handles_Class[handles(Class)]
+
--
Whether this marshaller is able to marshall/unmarshall the provided Java class.
--
<.> xref:#getGqlScalarType_[getGqlScalarType()]
+
--
The corresponding GraphQL scalar type for the Java-class.
--
<.> xref:#unmarshal_Object_Class[unmarshal(Object, Class)]
+
--
Unmarshal the provided graphQL value into its Java equivalent.
--

== Members

[#handles_Class]
=== handles(Class)

Whether this marshaller is able to marshall/unmarshall the provided Java class.

[#getGqlScalarType_]
=== getGqlScalarType()

The corresponding GraphQL scalar type for the Java-class.

[#unmarshal_Object_Class]
=== unmarshal(Object, Class)

Unmarshal the provided graphQL value into its Java equivalent.
