本文整理了Java中rx.Notification.getKind()
方法的一些代码示例,展示了Notification.getKind()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification.getKind()
方法的具体详情如下:
包路径:rx.Notification
类名称:Notification
方法名:getKind
[英]Retrieves the kind of this notification: OnNext, OnError, or OnCompleted
[中]检索此通知的类型:OnNext、OnError或OnCompleted
代码示例来源:origin: konmik/nucleus
public void split(Action2<View, T> onNext, @Nullable Action2<View, Throwable> onError) {
if (notification.getKind() == Notification.Kind.OnNext)
onNext.call(view, notification.getValue());
else if (onError != null && notification.getKind() == Notification.Kind.OnError)
onError.call(view, notification.getThrowable());
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
/**
* Indicates whether this notification represents an {@code onError} event.
*
* @return a boolean indicating whether this notification represents an {@code onError} event
*/
public boolean isOnError() {
return getKind() == Kind.OnError;
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
/**
* Indicates whether this notification represents an {@code onCompleted} event.
*
* @return a boolean indicating whether this notification represents an {@code onCompleted} event
*/
public boolean isOnCompleted() {
return getKind() == Kind.OnCompleted;
}
代码示例来源:origin: com.novoda/rxmocks
@Override
public boolean matches(Notification<T> actual) {
return actual.getKind() == Notification.Kind.OnNext;
}
代码示例来源:origin: com.novoda/rxmocks
@Override
public boolean matches(Notification<T> actual) {
return actual.getKind() == Notification.Kind.OnError;
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
/**
* Indicates whether this notification represents an {@code onNext} event.
*
* @return a boolean indicating whether this notification represents an {@code onNext} event
*/
public boolean isOnNext() {
return getKind() == Kind.OnNext;
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
@Override
public String toString() {
StringBuilder str = new StringBuilder("[").append(super.toString()).append(" ").append(getKind());
if (hasValue())
str.append(" ").append(getValue());
if (hasThrowable())
str.append(" ").append(getThrowable().getMessage());
str.append("]");
return str.toString();
}
代码示例来源:origin: com.novoda/rxmocks
@Override
public void call(Notification<T> notification) {
if (matcher.matches(notification)) {
noMatch = false;
matched.call(notification);
}
if (notification.getKind() == Notification.Kind.OnCompleted && noMatch) {
throw new RuntimeException("Expected " + matcher.description() + " but completed without matching");
}
}
};
代码示例来源:origin: com.netflix.rxjava/rxjava-core
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (this == obj)
return true;
if (obj.getClass() != getClass())
return false;
Notification<?> notification = (Notification<?>) obj;
if (notification.getKind() != getKind())
return false;
if (hasValue() && !getValue().equals(notification.getValue()))
return false;
if (hasThrowable() && !getThrowable().equals(notification.getThrowable()))
return false;
return true;
}
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
@Override
public int hashCode() {
int hash = getKind().hashCode();
if (hasValue())
hash = hash * 31 + getValue().hashCode();
if (hasThrowable())
hash = hash * 31 + getThrowable().hashCode();
return hash;
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
@Override
public void onNext(Notification<T> t) {
switch (t.getKind()) {
case OnNext:
if (!terminated) {
child.onNext(t.getValue());
}
break;
case OnError:
onError(t.getThrowable());
break;
case OnCompleted:
onCompleted();
break;
}
}
代码示例来源:origin: com.netflix.eureka/eureka2-eureka1-rest-api
@Override
public Observable<Void> call(List<Notification<InstanceInfo>> notifications) {
// If completed with error propagate it
Notification<InstanceInfo> lastNotification = notifications.get(notifications.size() - 1);
if (lastNotification.getKind() == Kind.OnError) {
return Observable.error(lastNotification.getThrowable());
}
// If onComplete only => instance info not found
if (notifications.size() == 1) {
logger.info("Instance info with id {} not found", instanceId);
response.setStatus(HttpResponseStatus.NOT_FOUND);
return Observable.empty();
}
// InstanceInfo object found
InstanceInfo v1InstanceInfo = notifications.get(0).getValue();
if (appName != null && !appName.equalsIgnoreCase(v1InstanceInfo.getAppName())) {
logger.info("Instance info with id {} is associated with application {}, not {}",
instanceId, v1InstanceInfo.getAppName(), appName);
response.setStatus(HttpResponseStatus.NOT_FOUND);
return Observable.empty();
}
return encodeResponse(format, gzip, response, v1InstanceInfo);
}
}
内容来源于网络,如有侵权,请联系作者删除!