DMRLocationResolver implements LocationResolver<DMRNodeLocation> { @Override public boolean isParent(DMRNodeLocation parent, DMRNodeLocation child) { if (parent == null) { throw new IllegalArgumentException( "Cannot compute [" + getClass().getName() + "].isParent() with a null parent argument"); } if (child == null) { throw new IllegalArgumentException( "Cannot compute [" + getClass().getName() + "].isParent() with a null child argument"); } PathAddress parentPath = parent.getPathAddress(); PathAddress childPath = child.getPathAddress(); int parentLength = parentPath.size(); if (parentLength < childPath.size()) { return matches(parentLength, parentPath, childPath); } else { return false; } }  @Override DMRNodeLocation buildLocation(String path); @Override String findWildcardMatch(DMRNodeLocation multiTargetLocation, DMRNodeLocation singleLocation); @Override boolean isMultiTarget(DMRNodeLocation location); @Override DMRNodeLocation absolutize(DMRNodeLocation base, DMRNodeLocation location); @Override boolean isParent(DMRNodeLocation parent, DMRNodeLocation child); @Override boolean matches(DMRNodeLocation query, DMRNodeLocation location); @Override String applyTemplate(String nameTemplate, DMRNodeLocation location, String endpointName);  }
@Test public void testIsParent() throws Exception { DMRLocationResolver res = new DMRLocationResolver(); Assert.assertTrue(res.isParent(DMRNodeLocation.empty(), DMRNodeLocation.of("/one=1"))); Assert.assertTrue(res.isParent(DMRNodeLocation.of("/"), DMRNodeLocation.of("/one=1"))); Assert.assertTrue(res.isParent(DMRNodeLocation.of("/one=1"), DMRNodeLocation.of("/one=1/two=2"))); Assert.assertTrue(res.isParent(DMRNodeLocation.of("/o=1/t=2"), DMRNodeLocation.of("/o=1/t=2/thr=3"))); Assert.assertFalse(res.isParent(DMRNodeLocation.of("/one=1"), DMRNodeLocation.of("/one=1"))); Assert.assertFalse(res.isParent(DMRNodeLocation.of("/one=1"), DMRNodeLocation.of("/two=2"))); Assert.assertTrue(res.isParent(DMRNodeLocation.of("/one=1"), DMRNodeLocation.of("/one=1/two=2/three=3"))); }