Skip to content

Commit

Permalink
[Issue mpollmeier#166] Make ScalaElement.updateWith(x) remove propert…
Browse files Browse the repository at this point in the history
…ies which are None in x
  • Loading branch information
Matthew committed Aug 19, 2016
1 parent 30a8b63 commit c87b542
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ trait ScalaElement[ElementType <: Element] {

def updateWith[CC <: Product: Marshallable](update: CC): ElementType = {
val propMap = implicitly[Marshallable[CC]].fromCC(update).valueMap
propMap foreach {case (prop, value) => element.property(prop, value)}
this.valueMap.keySet.diff(propMap.keySet) foreach { key =>
val prop = element.property(key)
if (prop.isPresent) prop.remove()
}
propMap foreach {case (key, value) => element.property(key, value)}

element
}
Expand Down

0 comments on commit c87b542

Please sign in to comment.