public static Type preserveType(Type currentType, Type newType) {
        Type result = newType;
        if (newType != null && currentType != null &&
            currentType.getObjectClass() == newType.getObjectClass()) {
            if (newType.getGenericType().getGenericType() instanceof Class &&
                !(currentType.getGenericType().getGenericType() instanceof Class)) {
                if (newType.isNonNull() && !currentType.isNonNull()) {
                    result = currentType.toNonNull();
                }
                else if (!newType.isNonNull() && currentType.isNonNull()) {
                    result = currentType.toNullable();
                }
            }
        }

        return result;
    }