forked from redhat-developer/intellij-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for generateName (redhat-developer#549)
Signed-off-by: Andre Dietisheim <[email protected]>
- Loading branch information
Showing
2 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/ResourceIdentifier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package com.redhat.devtools.intellij.kubernetes.model.resource | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata | ||
|
||
class ResourceIdentifier(val name: String?, val generateName: String?, val namespace: String, private val resourceKind: ResourceKind<*>) { | ||
constructor(resource: HasMetadata) : this( | ||
resource.metadata.name, | ||
resource.metadata.generateName, | ||
resource.metadata.namespace, | ||
ResourceKind.create(resource) | ||
) | ||
val kind: String | ||
get() { | ||
return resourceKind.kind | ||
} | ||
val version: String | ||
get() { | ||
return resourceKind.version | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as ResourceIdentifier | ||
|
||
if (name != other.name) return false | ||
if (generateName != other.generateName) return false | ||
if (namespace != other.namespace) return false | ||
if (kind != other.kind) return false | ||
if (version != other.version) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = name.hashCode() | ||
result = 31 * result + namespace.hashCode() | ||
result = 31 * result + kind.hashCode() | ||
result = 31 * result + version.hashCode() | ||
return result | ||
} | ||
|
||
} |