Address implements Cloneable { public static Address parse(String addressStr) { Address address = root(); if (addressStr == null) { return address; } addressStr = addressStr.trim(); if (addressStr.isEmpty()) { return address; } String[] resources = addressStr.split("/"); for (String resource : resources) { resource = resource.trim(); if (resource.isEmpty()) { continue; } String[] typeAndName = resource.split("="); String type = typeAndName[0].trim(); String name = (typeAndName.length == 2) ? typeAndName[1].trim() : ""; address.add(type, name); } return address; } Address();  Address(String... addressParts); static Address root(); static Address parse(String addressStr); static Address fromModelNode(ModelNode node); static Address fromModelNodeWrapper(ModelNode haystack, String needle); ModelNode getAddressNode(); Address add(String... addressParts); Address add(String type, String name); Address add(Address address); boolean isRoot(); String[] toAddressParts(); String toAddressPathString(); @Override Address clone(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testParse() { Address addr = Address.parse("/parent=foo"); assert addr.getAddressNode().asList().size() == 1; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals("foo"); addr = Address.parse("/parent=foo/child=bar"); assert addr.getAddressNode().asList().size() == 2; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals("foo"); assert addr.getAddressNode().asList().get(1).get("child").asString().equals("bar"); addr = Address.parse("/parent=foo/child=bar/"); assert addr.getAddressNode().asList().size() == 2; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals("foo"); assert addr.getAddressNode().asList().get(1).get("child").asString().equals("bar"); addr = Address.parse("parent=foo/child=bar"); assert addr.getAddressNode().asList().size() == 2; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals("foo"); assert addr.getAddressNode().asList().get(1).get("child").asString().equals("bar"); addr = Address.parse("/a-b-c=x-y-z/a_b_c=x_y_z"); assert addr.getAddressNode().asList().size() == 2; assert addr.getAddressNode().asList().get(0).get("a-b-c").asString().equals("x-y-z"); assert addr.getAddressNode().asList().get(1).get("a_b_c").asString().equals("x_y_z"); addr = Address.parse("/parent"); assert addr.getAddressNode().asList().size() == 1; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals(""); addr = Address.parse("/parent="); assert addr.getAddressNode().asList().size() == 1; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals(""); addr = Address.parse("/parent=/child="); assert addr.getAddressNode().asList().size() == 2; assert addr.getAddressNode().asList().get(0).get("parent").asString().equals(""); assert addr.getAddressNode().asList().get(1).get("child").asString().equals(""); }