All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sop.ByteArrayAndResult.kt Maven / Gradle / Ivy

There is a newer version: 10.0.3
Show newest version
// SPDX-FileCopyrightText: 2023 Paul Schaub 
//
// SPDX-License-Identifier: Apache-2.0

package sop

import java.io.InputStream

/**
 * Tuple of a [ByteArray] and associated result object.
 *
 * @param bytes byte array
 * @param result result object
 * @param  type of result
 */
data class ByteArrayAndResult(val bytes: ByteArray, val result: T) {

    /**
     * [InputStream] returning the contents of [bytes].
     *
     * @return input stream
     */
    val inputStream: InputStream
        get() = bytes.inputStream()

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ByteArrayAndResult<*>

        if (!bytes.contentEquals(other.bytes)) return false
        if (result != other.result) return false

        return true
    }

    override fun hashCode(): Int {
        var hashCode = bytes.contentHashCode()
        hashCode = 31 * hashCode + (result?.hashCode() ?: 0)
        return hashCode
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy