JMXLocationResolver implements LocationResolver<JMXNodeLocation> { @Override public boolean isParent(JMXNodeLocation parent, JMXNodeLocation 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"); } ObjectName parentObjectName = parent.getObjectName(); ObjectName childObjectName = child.getObjectName(); if (!parentObjectName.getDomain().equals(childObjectName.getDomain())) { return false; } int parentKeyCount = parent.getCanonicalKeys().size(); int childKeyCount = child.getCanonicalKeys().size(); if (parentKeyCount >= childKeyCount) { return false; } for (String parentKey : parent.getCanonicalKeys()) { String parentKeyValue = parentObjectName.getKeyProperty(parentKey); if (!parentKeyValue.equals(childObjectName.getKeyProperty(parentKey))) { return false; } } return true; }  @Override JMXNodeLocation buildLocation(String path); @Override String findWildcardMatch(JMXNodeLocation multiTargetLocation, JMXNodeLocation singleLocation); @Override boolean isMultiTarget(JMXNodeLocation location); @Override JMXNodeLocation absolutize(JMXNodeLocation base, JMXNodeLocation location); @Override boolean isParent(JMXNodeLocation parent, JMXNodeLocation child); @Override boolean matches(JMXNodeLocation query, JMXNodeLocation location); @Override String applyTemplate(String nameTemplate, JMXNodeLocation location, String endpointName);  }
@Test public void testIsParent() throws Exception { JMXLocationResolver jmx = new JMXLocationResolver(); Assert.assertFalse( jmx.isParent(new JMXNodeLocation("domain:one=1"), new JMXNodeLocation("domain:two=2"))); Assert.assertFalse( jmx.isParent(new JMXNodeLocation("domain:one=1"), new JMXNodeLocation("domain:one=111"))); Assert.assertTrue( jmx.isParent(new JMXNodeLocation("domain:one=1,two=2"), new JMXNodeLocation("domain:one=1,two=2,three=3"))); Assert.assertTrue( jmx.isParent(new JMXNodeLocation("domain:one=1"), new JMXNodeLocation("domain:one=1,two=2,three=3"))); }