private ElementKey<?,?> calculateKey(ElementKey<?,?> key,ElementKey<?,?> sourceKey){
  Class<?> keyType=key.getElementType();
  Class<? extends Element> sourceType=sourceKey.getElementType();
  if (keyType != sourceType && keyType.isAssignableFrom(sourceType)) {
    key=ElementKey.of(key.getId(),key.getDatatype(),sourceType);
  }
  return key;
}

private ElementKey < ? , ? > calculateKey ( ElementKey < ? , ? > key , ElementKey < ? , ? > sourceKey ) { Class < ? > keyType = key . getElementType ( ) ; Class < ? extends Element > sourceType = sourceKey . getElementType ( ) ; if ( keyType != sourceType && keyType . isAssignableFrom ( sourceType ) ) { key = ElementKey . of ( key . getId ( ) , key . getDatatype ( ) , sourceType ) ; } return key ; }
calculates the actual key that should be used for adding an element . this uses the id and datatype of the key , but if the element types are in the same type hierarchy the narrowest element type is used .
