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,37 +31,81 @@ 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
+ return other is Different
65
+ && other.exists == exists
66
+ && other.isOutdatedVersion == isOutdatedVersion
67
+ && other.isPush() == isPush()
68
+ }
69
+
70
+ override fun hashCode (): Int {
71
+ return Objects .hash(
72
+ exists,
73
+ isOutdatedVersion,
74
+ isPush()
75
+ )
76
+ }
38
77
}
39
78
40
79
open class Modified (exists : Boolean , isOutdatedVersion : Boolean ): Different(exists, isOutdatedVersion) {
41
80
override fun isPush () = true
42
81
}
43
82
44
- class DeletedOnCluster : Modified (false , false ) {
83
+ class DeletedOnCluster () : Modified(false , false ) {
45
84
override fun isPush () = true
46
-
47
85
}
48
86
49
87
class Outdated : Different (true , true ) {
50
88
override fun isPush () = false
51
-
52
89
}
53
90
54
91
abstract class Pushed : Identical () {
55
92
abstract val updated: Boolean
56
- }
57
93
58
- class Created : Pushed () {
59
- override val updated = false
60
- }
61
- class Updated : Pushed () {
62
- override val updated = true
94
+ override fun equals (other : Any? ): Boolean {
95
+ if (this == = other) {
96
+ return true
97
+ }
98
+ return other is Pushed
99
+ && other.updated == updated
100
+ }
101
+
102
+ override fun hashCode (): Int {
103
+ return Objects .hashCode(updated)
104
+ }
63
105
}
64
106
107
+ class Created (override val updated : Boolean = false ) : Pushed()
108
+
109
+ class Updated (override val updated : Boolean = true ): Pushed()
110
+
65
111
class Pulled : EditorResourceState ()
0 commit comments