<commit_before>package org.firezenk.kartographer.library.types

import org.firezenk.kartographer.annotations.RouteAnimation
import java.util.*

/**
 * Project: Kartographer
 *
 * Created by <NAME>, aka firezenk on 20/09/17.
 * Copyright © <NAME> 2017
 */
class Route<B> (val clazz: Any, val params: Any, var path: Path,
                var viewParent: Any?, val animation: RouteAnimation?, val forResult: Int = -1) {

    val uuid: UUID = UUID.randomUUID()
    var bundle: B? = null
    var internalParams: Map<String, Any>? = null

    companion object {
        fun <B> areRoutesEqual(prev: Route<B>, next: Route<B>) =
                prev == next && (prev.bundle != null && (prev.bundle as B?)!! == next.bundle
                        || prev.internalParams != null && Arrays.equals(
                        prev.internalParams!!.values.toTypedArray(), next.internalParams!!.values.toTypedArray()))
    }

    init {
        try {
            internalParams = params as Map<String, Any>
            internalParams?.plus("uuid" to uuid)
        } catch (ex: ClassCastException) {
            bundle = params as B
        }
    }

    override fun equals(other: Any?) = other is Route<*> && clazz == other.clazz

    override fun toString() = "Route name: ${clazz.javaClass.simpleName}, on path: $path, has bundle? ${(bundle != null)}, has params? ${(internalParams != null)} (${internalParams?.keys})"

    override fun hashCode(): Int {
        var result = clazz.hashCode()
        result = 31 * result + params.hashCode()
        result = 31 * result + (viewParent?.hashCode() ?: 0)
        result = 31 * result + forResult
        result = 31 * result + uuid.hashCode()
        result = 31 * result + (bundle?.hashCode() ?: 0)
        result = 31 * result + (internalParams?.let { Arrays.hashCode(it.values.toTypedArray()) } ?: 0)
        return result
    }

    fun <B> copy(replacementParams: B) = Route<B>(clazz, replacementParams as Any, path, viewParent, animation, forResult)

    fun copy(replacementParams: Map<String, Any>) = Route<Any>(clazz, replacementParams, path, viewParent, animation, forResult)
}<commit_msg>Create new route classes easier to identify and clasify<commit_after>package org.firezenk.kartographer.library.types

import org.firezenk.kartographer.annotations.RouteAnimation
import java.util.*

/**
 * Project: Kartographer
 *
 * Created by <NAME>, aka firezenk on 20/09/17.
 * Copyright © <NAME> 2017
 */
sealed class Route

class ViewRoute(private val clazz: Any, val params: Map<String, Any>, var path: Path, var viewParent: Any,
                val animation: RouteAnimation?, val forResult: Int = -1) : Route() {

    val uuid: UUID = UUID.randomUUID()

    companion object {
        fun areRoutesEqual(prev: ViewRoute, next: ViewRoute) =
                prev == next && Arrays.equals(prev.params.values.toTypedArray(), next.params.values.toTypedArray())
    }

    override fun equals(other: Any?) = other is ViewRoute && clazz == other.clazz

    override fun toString() = "Route name: ${clazz.javaClass.simpleName}, on path: $path, params: (${params.keys})"

    override fun hashCode(): Int {
        var result = clazz.hashCode()
        result = 31 * result + params.hashCode()
        result = 31 * result + viewParent.hashCode()
        result = 31 * result + forResult
        result = 31 * result + uuid.hashCode()
        return result
    }

    fun copy(replacementParams: Map<String, Any>)
            = ViewRoute(clazz, replacementParams, path, viewParent, animation, forResult)

}

class ContextRoute<out B>(private val clazz: Any, val bundle: B, var path: Path, val forResult: Int = -1) : Route() {

    val uuid: UUID = UUID.randomUUID()

    companion object {
        fun <B> areRoutesEqual(prev: ContextRoute<B>, next: ContextRoute<B>) =
                prev == next && (prev.bundle != null && (prev.bundle as B?)!! == next.bundle)
    }

    override fun equals(other: Any?) = other is ContextRoute<*> && clazz == other.clazz

    override fun toString() = "Route name: ${clazz.javaClass.simpleName}, on path: $path, has bundle? ${(bundle != null)}"

    override fun hashCode(): Int {
        var result = clazz.hashCode()
        result = 31 * result + forResult
        result = 31 * result + uuid.hashCode()
        result = 31 * result + (bundle?.hashCode() ?: 0)
        return result
    }

    fun <B> copy(replacementParams: B) = ContextRoute<B>(clazz, replacementParams, path, forResult)
}

class ExternalRoute(private val clazz: Any) : Route()
{'fraction_non_alphanumeric': 0.13261013947310163, 'fraction_numerical': 0.01173345140580031, 'mean_word_length': 2.952755905511811, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3021559', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1326, 'n_words': 395}