DMRLocationResolver implements LocationResolver<DMRNodeLocation> { @Override public DMRNodeLocation absolutize(DMRNodeLocation base, DMRNodeLocation location) { if (base == null || base.getPathAddress().equals(PathAddress.EMPTY_ADDRESS)) { return location; } else if (location == null) { return base; } else { PathAddress basePath = base.getPathAddress(); PathAddress path = ((DMRNodeLocation) location).getPathAddress(); if (path.equals(PathAddress.EMPTY_ADDRESS)) { return new DMRNodeLocation(base.getPathAddress(), location.getResolveExpressions(), location.getIncludeDefaults()); } else { List<PathElement> segments = new ArrayList<>(basePath.size() + path.size()); for (PathElement segment : basePath) { segments.add(segment); } for (PathElement segment : path) { segments.add(segment); } PathAddress absPath = PathAddress.pathAddress(segments); return new DMRNodeLocation(absPath, location.getResolveExpressions(), location.getIncludeDefaults()); } } }  @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 testAbsolutize() { DMRLocationResolver resolver = new DMRLocationResolver(); DMRNodeLocation abs; abs = resolver.absolutize(null, DMRNodeLocation.of("/two=2/three=3")); Assert.assertEquals("/two=2/three=3", abs.toString()); abs = resolver.absolutize(DMRNodeLocation.of("/two=2/three=3"), (DMRNodeLocation) null); Assert.assertEquals("/two=2/three=3", abs.toString()); abs = resolver.absolutize(DMRNodeLocation.empty(), DMRNodeLocation.of("/two=2/three=3")); Assert.assertEquals("/two=2/three=3", abs.toString()); abs = resolver.absolutize(DMRNodeLocation.of("/one=1"), DMRNodeLocation.of("/two=2/three=3")); Assert.assertEquals("/one=1/two=2/three=3", abs.toString()); }