public static PathAddress pathAddress ( final ModelNode node ) { if ( node . isDefined ( ) ) { // final List<Property> props = node.asPropertyList(); // Following bit is crap TODO; uncomment above and delete below // when bug is fixed final List < Property > props = new ArrayList < Property > ( ) ; String key = null ; for ( ModelNode element : node . asList ( ) ) { Property prop = null ; if ( element . getType ( ) == ModelType . PROPERTY || element . getType ( ) == ModelType . OBJECT ) { prop = element . asProperty ( ) ; } else if ( key == null ) { key = element . asString ( ) ; } else { prop = new Property ( key , element ) ; } if ( prop != null ) { props . add ( prop ) ; key = null ; } } if ( props . size ( ) == 0 ) { return EMPTY_ADDRESS ; } else { final Set < String > seen = new HashSet < String > ( ) ; final List < PathElement > values = new ArrayList < PathElement > ( ) ; int index = 0 ; for ( final Property prop : props ) { final String name = prop . getName ( ) ; if ( seen . add ( name ) ) { values . add ( new PathElement ( name , prop . getValue ( ) . asString ( ) ) ) ; } else { throw duplicateElement ( name ) ; } if ( index == 1 && name . equals ( SERVER ) && seen . contains ( HOST ) ) { seen . clear ( ) ; } index ++ ; } return new PathAddress ( Collections . unmodifiableList ( values ) ) ; } } else { return EMPTY_ADDRESS ; } }
Creates a PathAddress from the given ModelNode address . The given node is expected to be an address node .