@ Override public Optional < DataType > handleIntermediateGet ( TraversalStep traversalStep , Object tree , String key , TraversalStep . Operation op ) { Optional < Object > optSub = traversalStep . get ( tree , key ) ; Object sub = optSub . get ( ) ; if ( sub == null && op == TraversalStep . Operation . SET ) { // get our child to make the container object, so it will be happy with it sub = traversalStep . getChild ( ) . newContainer ( ) ; traversalStep . overwriteSet ( tree , key , sub ) ; } return Optional . of ( ( DataType ) sub ) ; }
Only make a new instance of a container object for SET if there is nothing there .