compareMap
#function compareMap($left, $right)
#if ($vs.util.isBlankOne($left, $right))
#set($result = $vs.util.newMap())
#set($result.left = $left)
#set($result.right = $right)
return $result
#elseif ($vs.util.isMap($left) and $vs.util.isMap($right))
#set($result = $vs.util.newMap())
#set($leftKeys = $vs.util.getMapKeys($left))
#set($rightKeys = $vs.util.getMapKeys($right))
#set($leftDifferenceKey = @differenceListStr($leftKeys, $rightKeys))
#set($rightDifferenceKey = @differenceListStr($rightKeys, $leftKeys))
#set($intersectionKey = @intersectionListStr($leftKeys, $rightKeys))
#set($nullKey = $vs.util.newList())
#set($leftMap = $vs.util.newMap())
#set($rightMap = $vs.util.newMap())
#set($intersectionMap = $vs.util.newMap())
#set($differenceMap = $vs.util.newMap())
#foreach ($key in $intersectionKey)
#set($leftValue = $left.get($key))
#set($rightValue = $right.get($key))
#if ($vs.util.isNull($leftValue) and $vs.util.isNull($rightValue))
$nullKey.add($key)
#end
#if ($vs.util.isNotNull($leftValue) and $vs.util.isNull($rightValue))
$leftMap.put($key, $leftValue)
#end
#if ($vs.util.isNotNull($rightValue) and $vs.util.isNull($leftValue))
$rightMap.put($key, $rightValue)
#end
#if ($vs.util.isMap($leftValue) and $vs.util.isMap($rightValue))
$result.put($key, @compareMap($leftValue, $rightValue))
#elseif ($vs.util.isList($leftValue) and $vs.util.isList($rightValue))
$result.put($key, @compareMap($leftValue, $rightValue))
#else
#if ($vs.util.equals($leftValue, $rightValue))
$intersectionMap.put($key, $leftValue)
#else
#set($differenceMapValue = $vs.util.newMap())
#set($differenceMapValue.left = $leftValue)
#set($differenceMapValue.right = $rightValue)
$differenceMap.put($key, $differenceMapValue)
#end
#end
#end
#set($data = $vs.util.newMap())
#if ($vs.util.isList($leftDifferenceKey) and $leftDifferenceKey.size() > 0)
#set($data.leftDifferenceKey = $leftDifferenceKey)
#end
#if ($vs.util.isList($rightDifferenceKey) and $rightDifferenceKey.size() > 0)
#set($data.rightDifferenceKey = $rightDifferenceKey)
#end
#if ($vs.util.isList($intersectionKey) and $intersectionKey.size() > 0)
#set($data.intersectionKey = $intersectionKey)
#end
#if ($vs.util.isList($nullKey) and $nullKey.size() > 0)
#set($data.nullKey = $nullKey)
#end
#set($keys = $vs.util.getMapKeys($leftMap))
#if ($vs.util.isMap($leftMap) and $keys.size() > 0)
#set($data.leftMap = $leftMap)
#end
#set($keys = $vs.util.getMapKeys($rightMap))
#if ($vs.util.isMap($rightMap) and $keys.size() > 0)
#set($data.rightMap = $rightMap)
#end
#set($keys = $vs.util.getMapKeys($intersectionMap))
#if ($vs.util.isMap($intersectionMap) and $keys.size() > 0)
#set($data.intersectionMap = $intersectionMap)
#end
#set($keys = $vs.util.getMapKeys($differenceMap))
#if ($vs.util.isMap($differenceMap) and $keys.size() > 0)
#set($data.differenceMap = $differenceMap)
#end
#set($result.data = $data)
return $result
#elseif ($vs.util.isList($left) and $vs.util.isList($right))
#set($result = $vs.util.newList())
#set($list = $left)
#if ($right.size() > $left.size())
#set($list = $right)
#end
#foreach ($row in $list)
#set($l = null)
#if($left.size() > $index)
#set($l = $left.get($index))
#end
#set($r = null)
#if($right.size() > $index)
#set($r = $right.get($index))
#end
$result.add(@compareMap($l, $r))
#end
return $result
#else
$vs.log.info($left)
$vs.log.info($right)
$vs.exception.throwException('compareMap')
return null
#end
#end
#function intersectionListStr ($left, $right)
#set($intersection = $vs.util.newList())
#foreach ($row in $left)
#if ($vs.util.isNotNull($row) and $right.contains($row) and !$intersection.contains($row))
$intersection.add($row)
#end
#end
#foreach ($row in $right)
#if ($vs.util.isNotNull($row) and $left.contains($row) and !$intersection.contains($row))
$intersection.add($row)
#end
#end
return $intersection
#end
#function differenceListStr ($left, $right)
#set($difference = $vs.util.newList())
#foreach ($row in $left)
#if ($vs.util.isNotNull($row) and !$right.contains($row) and !$difference.contains($row))
$difference.add($row)
#end
#end
return $difference
#end
leftEquals
#function leftEquals ($left, $right)
#if ($vs.util.isMap($left) and $vs.util.isMap($right))
#foreach ($key in $vs.util.getMapKeys($right))
#if ($left.get($key) ne $right.get($key))
return false
#end
#end
return true
#end
return false
#end