static void updateProperties ( Element e , Map < String , Object > properties , String [ ] disallowedProperties ) { if ( properties == null ) { return ; } Set < String > disallowed = new HashSet <> ( Arrays . asList ( disallowedProperties ) ) ; //remove all non-mapped properties, that are not in the update Spliterator < Property < ? > > sp = Spliterators . spliteratorUnknownSize ( e . properties ( ) , Spliterator . NONNULL & Spliterator . IMMUTABLE ) ; Property < ? > [ ] toRemove = StreamSupport . stream ( sp , false ) . filter ( ( p ) - > ! disallowed . contains ( p . key ( ) ) && ! properties . containsKey ( p . key ( ) ) ) . toArray ( Property [ ] :: new ) ; for ( Property < ? > p : toRemove ) { p . remove ( ) ; } //update and add new the properties properties . forEach ( ( p , v ) -> { if ( ! disallowed . contains ( p ) ) { e . property ( p , v ) ; } } ) ; }
Updates the properties of the element disregarding any changes of the disallowed properties