/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.spine3.base;

import java.lang.reflect.Type;
import java.util.Map;

import static com.google.common.base.Preconditions.checkNotNull;
import static org.spine3.base.StringifierRegistry.getStringifier;

/**
 * Utility class for working with {@code Stringifier}s.
 *
 * @author Alexander Yevsyukov
 * @author Illia Shepilov
 */
public class Stringifiers {

    private Stringifiers() {
        // Disable instantiation of this utility class.
    }

    /**
     * Converts the passed value to the string representation.
     *
     * <p>Use this method for converting non-generic objects. For generic objects,
     * please use {@link #toString(Object, Type)}.
     *
     * @param object the object to convert
     * @param <T>    the type of the object
     * @return the string representation of the passed object
     */
    public static <T> String toString(T object) {
        checkNotNull(object);
        return toString(object, object.getClass());
    }

    /**
     * Converts the passed value to the string representation.
     *
     * <p>This method must be used of the passed object is a generic type.
     *
     * @param <T>     the type of the object to convert
     * @param object  to object to convert
     * @param typeOfT the type of the passed object
     * @return the string representation of the passed object
     * @throws MissingStringifierException if passed value cannot be converted
     */
    public static <T> String toString(T object, Type typeOfT) {
        checkNotNull(object);
        checkNotNull(typeOfT);

        final Stringifier<T> stringifier = getStringifier(typeOfT);
        final String result = stringifier.convert(object);
        return result;
    }

    /**
     * Parses string to the appropriate value.
     *
     * @param <T>     the type of the value to return
     * @param str     the string to convert
     * @param typeOfT the type into which to convert the string
     * @return the parsed value from string
     * @throws MissingStringifierException if passed value cannot be converted
     */
    public static <T> T fromString(String str, Type typeOfT) {
        checkNotNull(str);
        checkNotNull(typeOfT);

        final Stringifier<T> stringifier = getStringifier(typeOfT);
        final T result = stringifier.reverse()
                                    .convert(str);
        return result;
    }

    /**
     * Obtains {@code Stringifier} for map.
     *
     * @param keyClass   the class of keys are maintained by this map
     * @param valueClass the class  of mapped values
     * @param <K>        the type of keys are maintained by this map
     * @param <V>        the type of mapped values
     * @return the stringifier for the map
     */
    public static <K, V> Stringifier<Map<K, V>> mapStringifier(Class<K> keyClass,
                                                               Class<V> valueClass) {
        final Stringifier<Map<K, V>> mapStringifier = new MapStringifier<>(keyClass, valueClass);
        return mapStringifier;
    }

    /**
     * @param keyClass   the class of keys are maintained by this map
     * @param valueClass the class  of mapped values
     * @param delimiter  the delimiter for the passed map elements via string
     * @param <K>        the type of keys are maintained by this map
     * @param <V>        the type of mapped values
     * @return the stringifier for the map
     */
    public static <K, V> Stringifier<Map<K, V>> mapStringifier(Class<K> keyClass,
                                                               Class<V> valueClass,
                                                               String delimiter) {
        final Stringifier<Map<K, V>> mapStringifier =
                new MapStringifier<>(keyClass, valueClass, delimiter);
        return mapStringifier;
    }
}

@@ -3915,24 +3915,90 @@
 lueClass) %7B%0A
+        checkNotNull(keyClass);%0A        checkNotNull(valueClass);%0A
         fina
@@ -4746,24 +4746,123 @@
 elimiter) %7B%0A
+        checkNotNull(keyClass);%0A        checkNotNull(valueClass);%0A        checkNotNull(delimiter);%0A
         fina

Add check for the method parameters.