// Path: src/main/java/pl/jalokim/propertiestojson/util/exception/ParsePropertiesException.java
// public class ParsePropertiesException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public static final String STRING_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringJsonTypeResolver.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String STRING_TO_JSON_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringToJsonTypeConverter.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String PROPERTY_KEY_NEEDS_TO_BE_STRING_TYPE = "Unsupported property key type: %s for key: %s, Property key needs to be a string type";
//     public static final String CANNOT_FIND_TYPE_RESOLVER_MSG = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public static final String CANNOT_FIND_JSON_TYPE_OBJ = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + " for property: %s, and object value: %s %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public ParsePropertiesException(String message) {
//         super(message);
//     }
// }


import java.lang.reflect.ParameterizedType;
import pl.jalokim.propertiestojson.resolvers.primitives.adapter.InvokedFromAdapter;
import pl.jalokim.propertiestojson.resolvers.primitives.delegator.InvokedFromDelegator;
import pl.jalokim.propertiestojson.util.exception.ParsePropertiesException;
package pl.jalokim.propertiestojson.resolvers.primitives.object;


public interface HasGenericType<T> {

    @SuppressWarnings("unchecked")
    @InvokedFromAdapter
    @InvokedFromDelegator
    default Class<?> resolveTypeOfResolver() {
        Class<?> currentClass = getClass();
        while (currentClass != null) {
            try {
                return (Class<T>) ((ParameterizedType) currentClass
                    .getGenericSuperclass()).getActualTypeArguments()[0];
            } catch (Exception ccx) {
                currentClass = currentClass.getSuperclass();
            }
        }
// Path: src/main/java/pl/jalokim/propertiestojson/util/exception/ParsePropertiesException.java
// public class ParsePropertiesException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public static final String STRING_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringJsonTypeResolver.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String STRING_TO_JSON_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringToJsonTypeConverter.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String PROPERTY_KEY_NEEDS_TO_BE_STRING_TYPE = "Unsupported property key type: %s for key: %s, Property key needs to be a string type";
//     public static final String CANNOT_FIND_TYPE_RESOLVER_MSG = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public static final String CANNOT_FIND_JSON_TYPE_OBJ = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + " for property: %s, and object value: %s %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public ParsePropertiesException(String message) {
//         super(message);
//     }
// }


// Path: src/main/java/pl/jalokim/propertiestojson/resolvers/primitives/object/HasGenericType.java
import java.lang.reflect.ParameterizedType;
import pl.jalokim.propertiestojson.resolvers.primitives.adapter.InvokedFromAdapter;
import pl.jalokim.propertiestojson.resolvers.primitives.delegator.InvokedFromDelegator;
import pl.jalokim.propertiestojson.util.exception.ParsePropertiesException;

package pl.jalokim.propertiestojson.resolvers.primitives.object;


public interface HasGenericType<T> {

    @SuppressWarnings("unchecked")
    @InvokedFromAdapter
    @InvokedFromDelegator
    default Class<?> resolveTypeOfResolver() {
        Class<?> currentClass = getClass();
        while (currentClass != null) {
            try {
                return (Class<T>) ((ParameterizedType) currentClass
                    .getGenericSuperclass()).getActualTypeArguments()[0];
            } catch (Exception ccx) {
                currentClass = currentClass.getSuperclass();
            }
        }
        throw new ParsePropertiesException("Cannot find generic type for resolver: " + getClass()