Report.kt 1.67 KB
Newer Older
Jonas Waeber's avatar
Jonas Waeber committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * mapper-service
 * Copyright (C) 2020 Memoriav
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package org.memobase

21
import com.beust.klaxon.Klaxon
Jonas Waeber's avatar
Jonas Waeber committed
22
import java.time.LocalDateTime
23

Jonas Waeber's avatar
Jonas Waeber committed
24
25
26
data class Report(
    val id: String,
    val status: String,
Jonas Waeber's avatar
Jonas Waeber committed
27
28
29
    val message: String,
    val step: String = "mapper-service",
    val timestamp: String = LocalDateTime.now().toString()
30
31
32
33
) {
    fun toJson(): String {
        return Klaxon().toJsonString(this)
    }
Jonas Waeber's avatar
Jonas Waeber committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

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

        other as Report

        if (id != other.id) return false
        if (status != other.status) return false
        if (message != other.message) return false
        if (step != other.step) return false

        return true
    }

    override fun hashCode(): Int {
        var result = id.hashCode()
        result = 31 * result + status.hashCode()
        result = 31 * result + message.hashCode()
        result = 31 * result + step.hashCode()
        return result
    }
56
}