public void deregister(Mapping mapping) {
    for (Object input : mapping.getInputs()) {
      MappedObjectState mappedObjectState = getMappedObjectState(input);
      if (mappedObjectState != null) {
        mappedObjectState.getMappings().remove(mapping);
      }
    }

    for (Object output : mapping.getOutputs()) {
      MappedObjectState mappedObjectState = getMappedObjectState(output);
      if (mappedObjectState != null) {
        mappedObjectState.getMappings().remove(mapping);
      }
    }
  }
 public Collection<? extends Mapping> getMappings(Object object) {
   MappedObjectState mappedObjectState = getMappedObjectState(object);
   if (mappedObjectState == null) {
     return Collections.emptySet();
   } else {
     return mappedObjectState.getMappings();
   }
 }
  public void refreshMappedObjectStates(Mapping subtree) {
    for (Object input : subtree.getInputs()) {
      for (Iterator<?> objects = domain.treeIterator(input); objects.hasNext(); ) {
        Object object = objects.next();
        MappedObjectState mappedObjectState = getMappedObjectState(object);
        if (mappedObjectState != null) {
          mappedObjectState.setInput();
        }
      }
    }

    for (Object output : subtree.getOutputs()) {
      for (Iterator<?> objects = domain.treeIterator(output); objects.hasNext(); ) {
        MappedObjectState mappedObjectState = getMappedObjectState(objects.next());
        if (mappedObjectState != null) {
          mappedObjectState.setOutput();
        }
      }
    }

    for (Iterator<Mapping> mappings = subtree.treeIterator(); mappings.hasNext(); ) {
      Mapping mapping = mappings.next();
      for (Object input : mapping.getInputs()) {
        MappedObjectState mappedObjectState = getMappedObjectState(input);
        if (mappedObjectState != null) {
          mappedObjectState.getMappings().add(mapping);
        }
      }

      for (Object output : mapping.getOutputs()) {
        MappedObjectState mappedObjectState = getMappedObjectState(output);
        if (mappedObjectState != null) {
          mappedObjectState.getMappings().add(mapping);
        }
      }
    }
  }