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()
@@ -25,16 +27,66 @@ val FILTER_PUSHED = { editorResource: EditorResource ->
25
27
editorResource.getState() is Pushed
26
28
}
27
29
28
- abstract class EditorResourceState
30
+ abstract class EditorResourceState {
31
+ override fun equals (other : Any? ): Boolean {
32
+ if (this == = other) {
33
+ return true
34
+ }
35
+ if (javaClass != other?.javaClass) {
36
+ return false
37
+ }
38
+ return true
39
+ }
40
+
41
+ override fun hashCode (): Int {
42
+ return Objects .hash()
43
+ }
44
+ }
29
45
30
46
class Error (val title : String , val message : String? = null ): EditorResourceState() {
31
47
constructor (title: String , e: Throwable ) : this (title, e.message)
48
+
49
+ override fun equals (other : Any? ): Boolean {
50
+ if (this == = other) {
51
+ return true
52
+ }
53
+ return other is Error
54
+ && title == other.title
55
+ && message == other.message
56
+ }
57
+
58
+ override fun hashCode (): Int {
59
+ return Objects .hash(
60
+ title,
61
+ message
62
+ )
63
+ }
32
64
}
33
65
34
66
open class Identical : EditorResourceState ()
35
67
36
68
abstract class Different (val exists : Boolean , val isOutdatedVersion : Boolean ): EditorResourceState() {
37
69
abstract fun isPush (): Boolean
70
+ override fun equals (other : Any? ): Boolean {
71
+ if (this == = other) {
72
+ return true
73
+ }
74
+ if (javaClass != other?.javaClass) {
75
+ return false
76
+ }
77
+ return other is Different
78
+ && other.exists == exists
79
+ && other.isOutdatedVersion == isOutdatedVersion
80
+ && other.isPush() == isPush()
81
+ }
82
+
83
+ override fun hashCode (): Int {
84
+ return Objects .hash(
85
+ exists,
86
+ isOutdatedVersion,
87
+ isPush()
88
+ )
89
+ }
38
90
}
39
91
40
92
open class Modified (exists : Boolean , isOutdatedVersion : Boolean ): Different(exists, isOutdatedVersion) {
@@ -43,23 +95,33 @@ open class Modified(exists: Boolean, isOutdatedVersion: Boolean): Different(exis
43
95
44
96
class DeletedOnCluster : Modified (false , false ) {
45
97
override fun isPush () = true
46
-
47
98
}
48
99
49
100
class Outdated : Different (true , true ) {
50
101
override fun isPush () = false
51
-
52
102
}
53
103
54
104
abstract class Pushed : Identical () {
55
105
abstract val updated: Boolean
56
- }
57
106
58
- class Created : Pushed () {
59
- override val updated = false
60
- }
61
- class Updated : Pushed () {
62
- override val updated = true
107
+ override fun equals (other : Any? ): Boolean {
108
+ if (this == = other) {
109
+ return true
110
+ }
111
+ if (javaClass != other?.javaClass) {
112
+ return false
113
+ }
114
+ return other is Pushed
115
+ && other.updated == updated
116
+ }
117
+
118
+ override fun hashCode (): Int {
119
+ return Objects .hashCode(updated)
120
+ }
63
121
}
64
122
123
+ class Created (override val updated : Boolean = false ) : Pushed()
124
+
125
+ class Updated (override val updated : Boolean = true ): Pushed()
126
+
65
127
class Pulled : EditorResourceState ()
0 commit comments