mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
Explain what 'deepCopy' means
This commit is contained in:
@@ -63,6 +63,13 @@ class MapUtils implements Serializable {
|
|||||||
m.putAll(updates)
|
m.putAll(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Provides a new map with the same content like the original map.
|
||||||
|
* Nested Collections and Maps are copied. Values with are not
|
||||||
|
* Collections/Maps are not copied/cloned.
|
||||||
|
* <paranoia>&/ltThe keys are also not copied/cloned, even if they are
|
||||||
|
* Maps or Collections;paranoia>
|
||||||
|
*/
|
||||||
static deepCopy(Map original) {
|
static deepCopy(Map original) {
|
||||||
Map copy = [:]
|
Map copy = [:]
|
||||||
for (def e : original.entrySet()) {
|
for (def e : original.entrySet()) {
|
||||||
@@ -75,14 +82,14 @@ class MapUtils implements Serializable {
|
|||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
static deepCopy(Set original) {
|
/* private */ static deepCopy(Set original) {
|
||||||
Set copy = []
|
Set copy = []
|
||||||
for(def e : original)
|
for(def e : original)
|
||||||
copy << deepCopy(e)
|
copy << deepCopy(e)
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
static deepCopy(List original) {
|
/* private */ static deepCopy(List original) {
|
||||||
List copy = []
|
List copy = []
|
||||||
for(def e : original)
|
for(def e : original)
|
||||||
copy << deepCopy(e)
|
copy << deepCopy(e)
|
||||||
@@ -93,7 +100,7 @@ class MapUtils implements Serializable {
|
|||||||
* In fact not a copy, but a catch all for everything not matching
|
* In fact not a copy, but a catch all for everything not matching
|
||||||
* with the other signatures
|
* with the other signatures
|
||||||
*/
|
*/
|
||||||
static deepCopy(def original) {
|
/* private */ static deepCopy(def original) {
|
||||||
original
|
original
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user