本文整理了Java中java.lang.NullPointerException.<init>()
方法的一些代码示例,展示了NullPointerException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NullPointerException.<init>()
方法的具体详情如下:
包路径:java.lang.NullPointerException
类名称:NullPointerException
方法名:<init>
[英]Constructs a new NullPointerException that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新NullPointerException。
代码示例来源:origin: square/okhttp
private CipherSuite(String javaName) {
if (javaName == null) {
throw new NullPointerException();
}
this.javaName = javaName;
}
代码示例来源:origin: square/okhttp
/** Change the level at which this interceptor logs. */
public HttpLoggingInterceptor setLevel(Level level) {
if (level == null) throw new NullPointerException("level == null. Use Level.NONE instead.");
this.level = level;
return this;
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Customizes the {@code Throwable} with a custom message and wraps it before it
* is signalled to the {@code RxJavaPlugins.onError()} handler as {@code OnErrorNotImplementedException}.
*
* @param message
* the message to assign to the {@code Throwable} to signal
* @param e
* the {@code Throwable} to signal; if null, a NullPointerException is constructed
*/
public OnErrorNotImplementedException(String message, @NonNull Throwable e) {
super(message, e != null ? e : new NullPointerException());
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void subscribe(MaybeObserver<? super Object> observer) {
throw new NullPointerException("Forced failure");
}
}).test();
代码示例来源:origin: ReactiveX/RxJava
/**
* Constructs a CompositeException with the given array of Throwables as the
* list of suppressed exceptions.
* @param exceptions the Throwables to have as initially suppressed exceptions
*
* @throws IllegalArgumentException if <code>exceptions</code> is empty.
*/
public CompositeException(@NonNull Throwable... exceptions) {
this(exceptions == null ?
Collections.singletonList(new NullPointerException("exceptions was null")) : Arrays.asList(exceptions));
}
代码示例来源:origin: ReactiveX/RxJava
/**
* Creates a NullPointerException instance and sets the given Throwable as its initial cause.
* @param ex the Throwable instance to use as cause, not null (not verified)
* @return the created NullPointerException
*/
private static NullPointerException toNpe(Throwable ex) {
NullPointerException npe = new NullPointerException("Actually not, but can't pass out an exception otherwise...");
npe.initCause(ex);
return npe;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
protected void subscribeActual(SingleObserver<? super Integer> observer) {
throw new NullPointerException();
}
}.test();
代码示例来源:origin: ReactiveX/RxJava
@Override
public void subscribe(CompletableObserver observer) {
throw new NullPointerException();
}
}).test();
代码示例来源:origin: square/retrofit
@SuppressWarnings("ConstantConditions") // Guarding public API nullability.
public static <T> Result<T> response(Response<T> response) {
if (response == null) throw new NullPointerException("response == null");
return new Result<>(response, null);
}
代码示例来源:origin: square/retrofit
@SuppressWarnings("ConstantConditions") // Guarding public API nullability.
public static <T> Result<T> error(Throwable error) {
if (error == null) throw new NullPointerException("error == null");
return new Result<>(null, error);
}
代码示例来源:origin: square/retrofit
/**
* Returns an instance which creates synchronous observables that
* {@linkplain Observable#subscribeOn(Scheduler) subscribe on} {@code scheduler} by default.
*/
@SuppressWarnings("ConstantConditions") // Guarding public API nullability.
public static RxJava2CallAdapterFactory createWithScheduler(Scheduler scheduler) {
if (scheduler == null) throw new NullPointerException("scheduler == null");
return new RxJava2CallAdapterFactory(scheduler, false);
}
代码示例来源:origin: square/okhttp
/** Returns a copy of this charset that expects a credential encoded with {@code charset}. */
public Challenge withCharset(Charset charset) {
if (charset == null) throw new NullPointerException("charset == null");
Map<String, String> authParams = new LinkedHashMap<>(this.authParams);
authParams.put("charset", charset.name());
return new Challenge(scheme, authParams);
}
代码示例来源:origin: square/okhttp
public Builder addEncoded(String name, String value) {
if (name == null) throw new NullPointerException("name == null");
if (value == null) throw new NullPointerException("value == null");
names.add(HttpUrl.canonicalize(name, FORM_ENCODE_SET, true, false, true, true, charset));
values.add(HttpUrl.canonicalize(value, FORM_ENCODE_SET, true, false, true, true, charset));
return this;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable t) {
if (terminate) {
RxJavaPlugins.onError(t);
} else {
if (t == null) {
t = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources.");
}
terminate = true;
downstream.onError(t);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onError(Throwable t) {
if (terminate) {
RxJavaPlugins.onError(t);
} else {
if (t == null) {
t = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources.");
}
terminate = true;
downstream.onError(t);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (done || isCancelled()) {
return;
}
if (t == null) {
onError(new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
return;
}
queue.set(t);
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (t == null) {
onError(new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
return;
}
if (!isDisposed()) {
observer.onNext(t);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void onNext(T t) {
if (done || isCancelled()) {
return;
}
if (t == null) {
onError(new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
return;
}
queue.offer(t);
drain();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void subscribe(Subscriber<? super Flowable<String>> op) {
op.onSubscribe(new BooleanSubscription());
op.onNext(Flowable.unsafeCreate(f1));
op.onNext(Flowable.unsafeCreate(f2));
op.onError(new NullPointerException("throwing exception in parent"));
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void subscribe(Observer<? super Observable<String>> op) {
op.onSubscribe(Disposables.empty());
op.onNext(Observable.unsafeCreate(o1));
op.onNext(Observable.unsafeCreate(o2));
op.onError(new NullPointerException("throwing exception in parent"));
}
});
内容来源于网络,如有侵权,请联系作者删除!