11
11
******************************************************************************/
12
12
package com.redhat.devtools.intellij.kubernetes.editor
13
13
14
+ import java.util.Objects
15
+
14
16
val FILTER_ALL = { _: EditorResource -> true }
15
17
val FILTER_TO_PUSH = { editorResource: EditorResource ->
16
18
val state = editorResource.getState()
@@ -29,12 +31,52 @@ abstract class EditorResourceState
29
31
30
32
class Error (val title : String , val message : String? = null ): EditorResourceState() {
31
33
constructor (title: String , e: Throwable ) : this (title, e.message)
34
+
35
+ override fun equals (other : Any? ): Boolean {
36
+ if (this == = other) {
37
+ return true
38
+ }
39
+ return other is Error
40
+ && title == other.title
41
+ && message == other.message
42
+ }
43
+
44
+ override fun hashCode (): Int {
45
+ return Objects .hash(
46
+ title,
47
+ message
48
+ )
49
+ }
50
+
51
+ override fun toString (): String {
52
+ return super .toString()
53
+ }
32
54
}
33
55
34
56
open class Identical : EditorResourceState ()
35
57
36
58
abstract class Different (val exists : Boolean , val isOutdatedVersion : Boolean ): EditorResourceState() {
37
59
abstract fun isPush (): Boolean
60
+ override fun equals (other : Any? ): Boolean {
61
+ if (this == = other) {
62
+ return true
63
+ }
64
+ if (javaClass != other?.javaClass) {
65
+ return false
66
+ }
67
+ return other is Different
68
+ && other.exists == exists
69
+ && other.isOutdatedVersion == isOutdatedVersion
70
+ && other.isPush() == isPush()
71
+ }
72
+
73
+ override fun hashCode (): Int {
74
+ return Objects .hash(
75
+ exists,
76
+ isOutdatedVersion,
77
+ isPush()
78
+ )
79
+ }
38
80
}
39
81
40
82
open class Modified (exists : Boolean , isOutdatedVersion : Boolean ): Different(exists, isOutdatedVersion) {
@@ -43,23 +85,30 @@ open class Modified(exists: Boolean, isOutdatedVersion: Boolean): Different(exis
43
85
44
86
class DeletedOnCluster : Modified (false , false ) {
45
87
override fun isPush () = true
46
-
47
88
}
48
89
49
90
class Outdated : Different (true , true ) {
50
91
override fun isPush () = false
51
-
52
92
}
53
93
54
94
abstract class Pushed : Identical () {
55
95
abstract val updated: Boolean
56
- }
57
96
58
- class Created : Pushed () {
59
- override val updated = false
60
- }
61
- class Updated : Pushed () {
62
- override val updated = true
97
+ override fun equals (other : Any? ): Boolean {
98
+ if (this == = other) {
99
+ return true
100
+ }
101
+ return other is Pushed
102
+ && other.updated == updated
103
+ }
104
+
105
+ override fun hashCode (): Int {
106
+ return Objects .hashCode(updated)
107
+ }
63
108
}
64
109
110
+ class Created (override val updated : Boolean = false ) : Pushed()
111
+
112
+ class Updated (override val updated : Boolean = true ): Pushed()
113
+
65
114
class Pulled : EditorResourceState ()
0 commit comments