class SimpleManagedResource extends AbstractManagedResource {

   @Override
   public Registration registerSubResource(String name, ManagedDescription description)
   {
      if (name == null) throw new IllegalArgumentException("name is null");
      if (description == null) throw new IllegalArgumentException("description is null");

      if (name.charAt(0) == '/') name = name.substring(1, name.length());

      PathElement element;
      try
      {
         element = PathElement.pathElement(name);
      }
      catch (PatternSyntaxException e)
      {
         throw new ManagementException("Could not parse path template " + name, e);
      }

      SimpleManagedResource resource = new SimpleManagedResource(element, this, description);
      if (children.putIfAbsent(element.getValue(), resource) != null)
      {
         throw new IllegalArgumentException("Resource " + name + " already exists for path " + getPath());
      }

      return resource;
   }

}

class SimpleManagedResourceTest {

   private static final ManagedDescription ROOT_DESC;
   private static final ManagedDescription A_DESC;
   private static final ManagedDescription A_1_DESC;
   private static final ManagedDescription A_1_1_DESC;
   private static final ManagedDescription A_2_DESC;
   private static final ManagedDescription B_DESC;
   private static final ManagedDescription C_DESC;
   private static final ManagedDescription C_1_DESC;
   private static final ManagedDescription C_1_1_DESC;
   private static final ManagedDescription WILDCARD_DESC;

   @Test
   public void testLocationString()
   {

      SimpleManagedResource root = createRootResource();

      SimpleManagedResource a = (SimpleManagedResource) root.registerSubResource("a", A_DESC);
      SimpleManagedResource a_1 = (SimpleManagedResource) a.registerSubResource("a-1", A_1_DESC);
      SimpleManagedResource a_1_1 = (SimpleManagedResource) a_1.registerSubResource("a-1-1", A_1_1_DESC);

      assertEquals("/a", a.getPath());
      assertEquals("/a/a-1", a_1.getPath());
      assertEquals("/a/a-1/a-1-1", a_1_1.getPath());
   }

}