Defer execution of some disposable object.

@param disposable some disposable object to be processed.
@return the same object from arguments
@throws AssertionError if the disposable object is null
@see Disposable
974029
@Weight(Weight.Unit.NORMAL)
  public static Disposable defer(@Nonnull final Disposable disposable) {
    assertNotNull(disposable);
    defer(new Deferred() {
      private static final long serialVersionUID = 7940162959962038010L;
      private final Disposable value = disposable;

      @Override
      public void executeDeferred() throws Exception {
        this.value.dispose();
      }
    });
    return disposable;
  }
240800
@Override
    public void verify() throws SniffyAssertionError {
        checkOpened();
        SniffyAssertionError assertionError = getSniffyAssertionError();
        if (null != assertionError) {
            throw assertionError;
        }
    }
85326
@SuppressWarnings("unused")
    static Void throwUnsafelyIfNonNull(@Nullable Object unused,
                                       @Nullable Throwable cause) {
        throwUnsafelyIfNonNull(cause);
        return null;
    }
971038
private static RuntimeException cancelThrow(ClientCall<?, ?> call, Throwable t) {
    try {
      call.cancel(null, t);
    } catch (Throwable e) {
      assert e instanceof RuntimeException || e instanceof Error;
      logger.log(Level.SEVERE, "RuntimeException encountered while closing call", e);
    }
    if (t instanceof RuntimeException) {
      throw (RuntimeException) t;
    } else if (t instanceof Error) {
      throw (Error) t;
    }
    // should be impossible
    throw new AssertionError(t);
  }
583700
public static AssertionError expectFailure(StandardSubjectBuilderCallback assertionCallback) {
    ExpectFailure expectFailure = new ExpectFailure();
    expectFailure.enterRuleContext(); // safe since this instance doesn't leave this method
    assertionCallback.invokeAssertion(expectFailure.whenTesting());
    return expectFailure.getFailure();
  }
887928
public <T> T checkSucceeds(Callable<T> callable) {
        try {
            return callable.call();
        } catch (Throwable e) {
            addError(e);
            return null;
        }
    }
341332
public static <E extends Exception> Runnable sneaked(SneakyRunnable<E> runnable) {
    return () -> {
      @SuppressWarnings("unchecked")
      SneakyRunnable<RuntimeException> castedRunnable = (SneakyRunnable<RuntimeException>) runnable;
      castedRunnable.run();
    };
  }
122468
public void dispose( DisposeHandler disposeHandler )
    {
        if ( disposeHandler == null )
        {
            disposeHandler = new NoOpDisposeHandler();
        }

        for ( Disposable disposable : disposables )
        {
            disposable.dispose( disposeHandler );
        }
    }
315397
@Override
    public boolean invokeEvictable(final T instance) throws DempsyException {
        return isEvictionSupported() ? (Boolean) wrap(() -> evictableMethod.invoke(instance)) : false;
    }
583786
public static synchronized <T> IExpectationSetters<T> expectPrivate(Object instance, String methodName,
                                                                        Class<?> where, Class<?>[] parameterTypes, Object... arguments) throws Exception {
        if (instance == null) {
            throw new IllegalArgumentException("Instance or class to expect cannot be null.");
        }
        Method[] methods = null;
        if (methodName != null) {
            if (parameterTypes == null) {
                methods = Whitebox.getMethods(where, methodName);
            } else {
                methods = new Method[]{Whitebox.getMethod(where, methodName, parameterTypes)};
            }
        }
        Method methodToExpect;
        if (methods != null && methods.length == 1) {
            methodToExpect = methods[0];
        } else {
            methodToExpect = WhiteboxImpl.findMethodOrThrowException(instance, null, methodName, arguments);
        }

        return doExpectPrivate(instance, methodToExpect, arguments);
    }
324204
TransactionOperationFactory assertStartedAndReturnFactory() {
      TransactionOperationFactory tmp = operationFactory;
      if (tmp == null) {
         throw getLog().transactionTableNotStarted();
      }
      return tmp;
   }
939967
@SuppressWarnings("unchecked")
    public static Closure ensureClosure(Object o) {
        if (o == null) throw new UnsupportedOperationException();
        if (o instanceof Closure) return (Closure) o;
        return new ReturnValueWrappingClosure(o);
    }
738255
@Override
    public <T> T createSpyComponent(final T instance) {
        checkArgument(instance != null, "instance must not be null!");
        if (isFinalOrPrimitive(instance.getClass())) {
            LOG.warn("Skipping creation of a spy : {} as it is final or primitive type.", instance.getClass()
                    .getSimpleName());
            return null;
        }
        return Mockito.spy(instance);
    }
519873
public static void gracefullyDisposeOf(final Map<?, ? extends Disposable> disposables) {
        if (disposables != null) {
            for (final Disposable disposable : disposables.values()) {
                gracefullyDisposeOf(disposable);
            }
        }
    }
1011467
Throwable getExpectedCause(Class expectedExceptionClass, 
			       Throwable exception) {
	Throwable result = exception.getCause();
	if (null != result) {
	    if (!expectedExceptionClass.isAssignableFrom(result.getClass())) {
		result = getExpectedCause(expectedExceptionClass, result);
	    }
	}
	return result;
    }
1134322
@Nonnull
  public static <T> T assertNotNull(@Nullable final T object) {
    return assertNotNull(null, object);
  }
1364565
public <T> T checkSucceeds(Callable<T> callable) {
        try {
            return callable.call();
        } catch (AssumptionViolatedException e) {
            AssertionError error = new AssertionError("Callable threw AssumptionViolatedException");
            error.initCause(e);
            addError(error);
            return null;
        } catch (Throwable e) {
            addError(e);
            return null;
        }
    }