public ParsedNode setValue ( Object value ) throws ParsedNodeException { if ( value instanceof ParsedNode ) { this . addChild ( ( ParsedNode ) value ) ; } else if ( value instanceof Collection ) { List newValue = new ArrayList ( ) ; for ( Object obj : ( ( Collection ) value ) ) { if ( obj instanceof Map ) { addChildren ( ( Map ) obj ) ; } else if ( obj instanceof ParsedNode ) { addChild ( ( ( ParsedNode ) obj ) ) ; } else { newValue . add ( obj ) ; } } if ( newValue . isEmpty ( ) ) { //do nothing } else if ( newValue . size ( ) == 1 ) { this . value = newValue . get ( 0 ) ; } else { this . value = newValue ; } } else if ( value instanceof Map ) { addChildren ( ( ( Map ) value ) ) ; } else { this . value = value ; } return this ; }
Sets the value of this ParsedNode . If the passed value is a ParsedNode it is added as a child not as the value . If the passed value is a Map it is converted to a ParsedNode and added as a child not as the value . If the passed value is a Collection each object is added as a child if it is a ParsedNode or a Map . If there are multiple simple values in a passed collection value is set to a List . If there is a single value in a collection value is set to the single value .