本文整理了Java中com.spotify.mobius.Next.modelUnsafe()
方法的一些代码示例,展示了Next.modelUnsafe()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Next.modelUnsafe()
方法的具体详情如下:
包路径:com.spotify.mobius.Next
类名称:Next
方法名:modelUnsafe
[英]Get the model of this Next. This version is unsafe - if this next doesn't have a model, calling this method will cause an exception to be thrown.
In almost all cases you should use #modelOrElse or #ifHasModel instead.
[中]下一步来看看这个模型。此版本不安全-如果此next没有模型,调用此方法将导致引发异常。
在几乎所有情况下,你都应该使用#modelOrElse或#ifHasModel。
代码示例来源:origin: spotify/mobius
@Override
protected boolean matchesSafely(Next<M, F> item, Description mismatchDescription) {
if (!item.hasModel()) {
mismatchDescription.appendText("no model");
return false;
} else if (!matcher.matches(item.modelUnsafe())) {
mismatchDescription.appendText("bad model: ");
matcher.describeMismatch(item.modelUnsafe(), mismatchDescription);
return false;
} else {
mismatchDescription.appendText("has a model: ");
matcher.describeMismatch(item.modelUnsafe(), mismatchDescription);
return true;
}
}
代码示例来源:origin: spotify/mobius
@Override
public void afterUpdate(M model, E event, Next<M, F> result) {
if (result.hasModel()) {
LOGGER.debug(LOGGING_PREFIX + "Model updated: {}", loggingTag, result.modelUnsafe());
}
for (F effect : result.effects()) {
LOGGER.debug(LOGGING_PREFIX + "Effect dispatched: {}", loggingTag, effect);
}
}
代码示例来源:origin: spotify/mobius
@Override
public void afterUpdate(M model, E event, Next<M, F> result) {
if (result.hasModel()) {
Log.d(tag, "Model updated: " + result.modelUnsafe());
}
for (F effect : result.effects()) {
Log.d(tag, "Effect dispatched: " + effect);
}
}
代码示例来源:origin: spotify/mobius
/**
* Try to get the model from this Next, with a fallback if there isn't one.
*
* @param fallbackModel the default model to use if the Next doesn't have a model
*/
@Nonnull
public M modelOrElse(M fallbackModel) {
checkNotNull(fallbackModel);
if (hasModel()) {
return modelUnsafe();
} else {
return fallbackModel;
}
}
代码示例来源:origin: com.spotify.mobius/mobius-core
/**
* Try to get the model from this Next, with a fallback if there isn't one.
*
* @param fallbackModel the default model to use if the Next doesn't have a model
*/
@Nonnull
public M modelOrElse(M fallbackModel) {
checkNotNull(fallbackModel);
if (hasModel()) {
return modelUnsafe();
} else {
return fallbackModel;
}
}
代码示例来源:origin: spotify/mobius
/** If the model is present, call the given consumer with it, otherwise do nothing. */
public void ifHasModel(Consumer<M> consumer) {
checkNotNull(consumer);
if (hasModel()) {
consumer.accept(modelUnsafe());
}
}
代码示例来源:origin: com.spotify.mobius/mobius-core
/** If the model is present, call the given consumer with it, otherwise do nothing. */
public void ifHasModel(Consumer<M> consumer) {
checkNotNull(consumer);
if (hasModel()) {
consumer.accept(modelUnsafe());
}
}
代码示例来源:origin: spotify/mobius
@Nonnull
public final Next<M, F> update(M model, E event) {
MI innerModel = checkNotNull(modelExtractor().apply(model));
EI innerEvent = checkNotNull(eventExtractor().apply(event));
Next<MI, FI> innerNext = checkNotNull(innerUpdate().update(innerModel, innerEvent));
M newModel = model;
boolean modelUpdated = innerNext.hasModel();
if (modelUpdated) {
newModel = checkNotNull(modelUpdater().apply(model, innerNext.modelUnsafe()));
}
return checkNotNull(
innerEffectHandler().handleInnerEffects(newModel, modelUpdated, innerNext.effects()));
}
内容来源于网络,如有侵权,请联系作者删除!