@@ -3,7 +3,7 @@ package com.coder.gateway.models
3
3
import com.intellij.openapi.components.BaseState
4
4
import com.intellij.util.xmlb.annotations.Attribute
5
5
6
- class RecentWorkspaceConnection () : BaseState() {
6
+ class RecentWorkspaceConnection () : BaseState(), Comparable<RecentWorkspaceConnection> {
7
7
constructor (hostname: String , prjPath: String , openedAt: String , productCode: String , buildNumber: String , source: String ) : this () {
8
8
coderWorkspaceHostname = hostname
9
9
projectPath = prjPath
@@ -30,4 +30,48 @@ class RecentWorkspaceConnection() : BaseState() {
30
30
31
31
@get:Attribute
32
32
var downloadSource by string()
33
+
34
+ override fun equals (other : Any? ): Boolean {
35
+ if (this == = other) return true
36
+ if (javaClass != other?.javaClass) return false
37
+ if (! super .equals(other)) return false
38
+
39
+ other as RecentWorkspaceConnection
40
+
41
+ if (coderWorkspaceHostname != other.coderWorkspaceHostname) return false
42
+ if (projectPath != other.projectPath) return false
43
+ if (ideProductCode != other.ideProductCode) return false
44
+ if (ideBuildNumber != other.ideBuildNumber) return false
45
+ if (downloadSource != other.downloadSource) return false
46
+
47
+ return true
48
+ }
49
+
50
+ override fun hashCode (): Int {
51
+ var result = super .hashCode()
52
+ result = 31 * result + (coderWorkspaceHostname?.hashCode() ? : 0 )
53
+ result = 31 * result + (projectPath?.hashCode() ? : 0 )
54
+ result = 31 * result + (ideProductCode?.hashCode() ? : 0 )
55
+ result = 31 * result + (ideBuildNumber?.hashCode() ? : 0 )
56
+ result = 31 * result + (downloadSource?.hashCode() ? : 0 )
57
+ return result
58
+ }
59
+
60
+ override fun compareTo (other : RecentWorkspaceConnection ): Int {
61
+ val i = other.coderWorkspaceHostname?.let { coderWorkspaceHostname?.compareTo(it) }
62
+ if (i != null && i != 0 ) return i
63
+
64
+ val j = other.projectPath?.let { projectPath?.compareTo(it) }
65
+ if (j != null && j != 0 ) return j
66
+
67
+ val k = other.ideProductCode?.let { ideProductCode?.compareTo(it) }
68
+ if (k != null && k != 0 ) return k
69
+
70
+ val l = other.ideBuildNumber?.let { ideBuildNumber?.compareTo(it) }
71
+ if (l != null && l != 0 ) return l
72
+
73
+ val m = other.downloadSource?.let { downloadSource?.compareTo(it) }
74
+ if (m != null && m != 0 ) return m
75
+ return 0
76
+ }
33
77
}
0 commit comments