code: public <DatastoreType, Instance> InstanceInvocationHandler<DatastoreType> getInvocationHandler(Instance instance) {
          Instance effectiveInstance;
          if (interceptorFactory.hasInterceptor(instance)) {
              effectiveInstance = interceptorFactory.removeInterceptor(instance);
          } else {
              effectiveInstance = instance;
          }
          InvocationHandler invocationHandler = Proxy.getInvocationHandler(effectiveInstance);
          if (!(invocationHandler instanceof InstanceInvocationHandler)) {
              throw new XOException("Instance " + instance + " implementing " + Arrays.asList(instance.getClass().getInterfaces()) + " is not a "
                      + InstanceInvocationHandler.class.getName());
          }
          return (InstanceInvocationHandler<DatastoreType>) invocationHandler;
      }
docs: Extracts the {@link com.buschmais.xo.impl.proxy.InstanceInvocationHandler}
  from a proxy instance.
  
  @param instance
  The proxy instance.
  @param <DatastoreType>
  The expected datastore type of the
  {@link com.buschmais.xo.impl.proxy.InstanceInvocationHandler}
  @param <Instance>
  The instance type.
  @return The {@link com.buschmais.xo.impl.proxy.InstanceInvocationHandler} .