- * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) any - * later version. - *
- * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.DayOfTheWeek;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link DayOfTheWeek}.
- */
-@ThreadSafe
-public final class DayOfTheWeekJacksonDeserializer extends ValueObjectStringJacksonDeserializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.DayOpeningHours;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link DayOpeningHours}.
- */
-@ThreadSafe
-public final class DayOpeningHoursJacksonDeserializer extends ValueObjectStringJacksonDeserializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.EmailAddress;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link EmailAddress}.
- */
-@ThreadSafe
-public final class EmailAddressJacksonDeserializer extends ValueObjectStringJacksonDeserializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.EmailAddress;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a {@link EmailAddress} into a String.
- */
-@ThreadSafe
-public final class EmailAddressJacksonSerializer extends ValueObjectStringJacksonSerializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.Hour;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link Hour}.
- */
-@ThreadSafe
-public final class HourJacksonDeserializer extends ValueObjectStringJacksonDeserializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.HourRange;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link HourRange}.
- */
-@ThreadSafe
-public final class HourRangeJacksonDeserializer extends ValueObjectStringJacksonDeserializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.HourRanges;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link HourRanges}.
- */
-@ThreadSafe
-public final class HourRangesJacksonDeserializer extends ValueObjectStringJacksonDeserializer
+ * To make the provider thread-safe for processing you need to finalize the instance
+ * by calling the {@link #mapper()} once your application startup has finished.
+ * For Spring and Quarkus a good option is to have another "@ApplicationScope"
+ * bean with a "@PostConstruct" method that will do it.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see http://www.gnu.org/licenses/.
+ */
+package org.fuin.objects4j.jackson;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.JsonSerializer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Utilities for the Jackson serialization module.
+ */
+public final class Objects4JacksonUtils {
+
+ /**
+ * Private utility constructor.
+ */
+ private Objects4JacksonUtils() {
+ throw new UnsupportedOperationException("Creating instances of a utility class is not allowed.");
+ }
+
+ /**
+ * Creates all available Jakcson serializers necessary for the ESC implementation.
+ *
+ * @return New array with serializers.
+ */
+ public static JsonSerializer>[] joinJacksonSerializers(final JsonSerializer>[] serializersA,
+ final JsonSerializer>... serializersB) {
+ return joinJacksonSerializerArrays(serializersA, serializersB);
+ }
+
+ /**
+ * Creates all available JSON-B serializers necessary for the ESC implementation.
+ *
+ * @return New array with serializers.
+ */
+ public static JsonSerializer>[] joinJacksonSerializerArrays(final JsonSerializer>[]... serializerArrays) {
+ final List
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.UserName;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts a String to a {@link UserName}.
- */
-@ThreadSafe
-public final class UserNameJacksonDeserializer extends ValueObjectStringJacksonDeserializer
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option) any
- * later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see http://www.gnu.org/licenses/.
- */
-package org.fuin.objects4j.jackson;
-
-import org.fuin.objects4j.core.WeeklyOpeningHours;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Converts String to a {@link WeeklyOpeningHours}.
- */
-@ThreadSafe
-public final class WeeklyOpeningHoursJacksonDeserializer extends ValueObjectStringJacksonDeserializer
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see http://www.gnu.org/licenses/.
+ */
+package org.fuin.objects4j.jackson;
+
+import com.fasterxml.jackson.core.JacksonException;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.fasterxml.jackson.databind.module.SimpleDeserializers;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.Currency;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests the {@link Objects4JacksonUtils} class.
+ */
+@SuppressWarnings("java:S1186") // Methods should not be empty is fine here for the test
+public class Objects4JacksonUtilsTest {
+
+ @Test
+ public void testJacksonJacksonSerializers() {
+
+ final JsonSerializer