本文整理汇总了Java中org.waveprotocol.wave.model.util.IdentityMap.Reduce类的典型用法代码示例。如果您正苦于以下问题:Java Reduce类的具体用法?Java Reduce怎么用?Java Reduce使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Reduce类属于org.waveprotocol.wave.model.util.IdentityMap包,在下文中一共展示了Reduce类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResult
import org.waveprotocol.wave.model.util.IdentityMap.Reduce; //导入依赖的package包/类
@Override
public R getResult() {
Reduce<Object, R, R> aggregator = new Reduce<Object, R, R>() {
@Override
public R apply(R soFar, Object key, R item) {
if (soFar != null) {
throw new IllegalStateException("scope contains multiple renderings");
} else {
return item;
}
}
};
// Thread aggregator through the rendering maps, ensuring there is at most
// one rendering in any of them.
R rendering = null;
rendering = result.getBlips().reduce(rendering, aggregator);
rendering = result.getThreads().reduce(rendering, aggregator);
rendering = result.getConversations().reduce(rendering, aggregator);
rendering = result.getWaves().reduce(rendering, aggregator);
return rendering;
}
示例2: getFirstConversation
import org.waveprotocol.wave.model.util.IdentityMap.Reduce; //导入依赖的package包/类
public UiBuilder getFirstConversation(IdentityMap<Conversation, UiBuilder> conversations) {
return conversations.reduce(null, new Reduce<Conversation, UiBuilder, UiBuilder>() {
@Override
public UiBuilder apply(UiBuilder soFar, Conversation key, UiBuilder item) {
// Pick the first rendering (any will do).
return soFar == null ? item : soFar;
}
});
}
示例3: render
import org.waveprotocol.wave.model.util.IdentityMap.Reduce; //导入依赖的package包/类
@Override
public TopConversationView render(
ConversationView wave, IdentityMap<Conversation, View> conversations) {
// Pick the first one.
return conversations.isEmpty() ? null :
conversations.reduce(null,
new Reduce<Conversation, View, TopConversationView>() {
@Override
public TopConversationView apply(
TopConversationView soFar, Conversation key, View item) {
return soFar != null ? soFar : (TopConversationView) item;
}
});
}
示例4: getFirstConversation
import org.waveprotocol.wave.model.util.IdentityMap.Reduce; //导入依赖的package包/类
private UiBuilder getFirstConversation(IdentityMap<Conversation, UiBuilder> conversations) {
return conversations.reduce(null, new Reduce<Conversation, UiBuilder, UiBuilder>() {
@Override
public UiBuilder apply(UiBuilder soFar, Conversation key, UiBuilder item) {
// Pick the first rendering (any will do).
return soFar == null ? item : soFar;
}
});
}
示例5: render
import org.waveprotocol.wave.model.util.IdentityMap.Reduce; //导入依赖的package包/类
@Override
public TopConversationView render(
ConversationView wave, IdentityMap<Conversation, View> conversations) {
// Pick the first one.
return conversations.isEmpty() ? null :
conversations.reduce(null, new Reduce<Conversation, View, TopConversationView>() {
@Override
public TopConversationView apply(TopConversationView soFar, Conversation key, View item) {
return soFar != null ? soFar : (TopConversationView) item;
}
});
}