本文整理了Java中scala.collection.JavaConversions.collectionAsScalaIterable()
方法的一些代码示例,展示了JavaConversions.collectionAsScalaIterable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JavaConversions.collectionAsScalaIterable()
方法的具体详情如下:
包路径:scala.collection.JavaConversions
类名称:JavaConversions
方法名:collectionAsScalaIterable
暂无
代码示例来源:origin: twosigma/beakerx
@SuppressWarnings("unchecked")
@Override
public Object deserialize(JsonNode n, ObjectMapper mapper) {
org.apache.commons.lang3.tuple.Pair<String, Object> deserializeObject = TableDisplayDeSerializer.getDeserializeObject(parent, n, mapper);
String subtype = deserializeObject.getLeft();
if (subtype != null && subtype.equals(TableDisplay.DICTIONARY_SUBTYPE)) {
return JavaConverters.mapAsScalaMapConverter((Map<String, Object>) deserializeObject.getRight()).asScala().toMap(Predef.<Tuple2<String, Object>>conforms());
} else if (subtype != null && subtype.equals(TableDisplay.LIST_OF_MAPS_SUBTYPE)) {
List<Map<String, Object>> rows = (List<Map<String, Object>>) deserializeObject.getRight();
List<Object> oo = new ArrayList<Object>();
for (Map<String, Object> row : rows) {
oo.add(JavaConverters.mapAsScalaMapConverter(row).asScala().toMap(Predef.<Tuple2<String, Object>>conforms()));
}
return scala.collection.JavaConversions.collectionAsScalaIterable(oo);
} else if (subtype != null && subtype.equals(TableDisplay.MATRIX_SUBTYPE)) {
List<List<?>> matrix = (List<List<?>>) deserializeObject.getRight();
ArrayList<Object> ll = new ArrayList<Object>();
for (List<?> ob : matrix) {
ll.add(scala.collection.JavaConversions.asScalaBuffer(ob).toList());
}
return scala.collection.JavaConversions.asScalaBuffer(ll).toList();
}
return deserializeObject.getRight();
}
代码示例来源:origin: com.typesafe.play/play_2.10
/**
* Select a preferred language, given the list of candidates.
*
* Will select the preferred language, based on what languages are available, or return the default language if
* none of the candidates are available.
*
* @param candidates The candidate languages
* @return The preferred language
*/
public Lang preferred(Collection<Lang> candidates) {
return new Lang(langs.preferred((scala.collection.Seq) JavaConversions.collectionAsScalaIterable(candidates).toSeq()));
}
}
代码示例来源:origin: com.typesafe.play/play_2.10
/**
* Get a messages context appropriate for the given candidates.
*
* Will select a language from the candidates, based on the languages available, and fallback to the default language
* if none of the candidates are available.
*/
public Messages preferred(Collection<Lang> candidates) {
Seq<Lang> cs = JavaConversions.collectionAsScalaIterable(candidates).toSeq();
play.api.i18n.Messages msgs = messages.preferred((Seq) cs);
return new Messages(new Lang(msgs.lang()), this);
}
代码示例来源:origin: apache/crunch
private static scala.collection.Iterable toIter(Object array) {
return JavaConversions.collectionAsScalaIterable((Collection) array);
}
代码示例来源:origin: com.mangofactory.swagger/swagger-models
@Override
public AllowableListValues apply(ApiModelProperty annotation) {
List<String> allowableValues
= Splitter.on(',').omitEmptyStrings().splitToList(nullToEmpty(annotation.allowableValues()));
return new AllowableListValues(JavaConversions.collectionAsScalaIterable(allowableValues).toList(), "LIST");
}
};
代码示例来源:origin: org.apache.storm/storm-druid
public List<E> update(List<TridentTuple> tuples, TridentCollector collector) {
List<E> events = new ArrayList<>(tuples.size());
for (TridentTuple tuple: tuples) {
events.add(druidEventMapper.getEvent(tuple));
}
LOG.info("Sending [{}] events", events.size());
scala.collection.immutable.List<E> scalaList = scala.collection.JavaConversions.collectionAsScalaIterable(events).toList();
Collection<Future<SendResult>> futureList = scala.collection.JavaConversions.asJavaCollection(beam.sendAll(scalaList));
List<E> discardedEvents = new ArrayList<>();
int index = 0;
for (Future<SendResult> future : futureList) {
try {
SendResult result = Await.result(future);
if (!result.sent()) {
discardedEvents.add(events.get(index));
}
} catch (Exception e) {
LOG.error("Failed in writing messages to Druid", e);
}
index++;
}
return discardedEvents;
}
代码示例来源:origin: SiftScience/kafka-assigner
JavaConversions.collectionAsScalaIterable(specifiedTopics).toSeq() :
zkUtils.getAllTopics();
代码示例来源:origin: com.mangofactory.swagger/swagger-models
public static AllowableValues allowableValues(ResolvedType resolvedType) {
if (isBaseType(simpleTypeName(resolvedType)) && resolvedType.getErasedType().isEnum()) {
List<String> enumValues = getEnumValues(resolvedType.getErasedType());
return new AllowableListValues(JavaConversions.collectionAsScalaIterable(enumValues).toList(), "LIST");
}
return null;
}
代码示例来源:origin: com.mangofactory.swagger/swagger-models
@Override
public com.google.common.base.Optional<Model> modelFor(ModelContext modelContext) {
ResolvedType propertiesHost = alternateTypeProvider.alternateFor(modelContext.resolvedType(resolver));
if (isContainerType(propertiesHost)
|| propertiesHost.getErasedType().isEnum()
|| Types.isBaseType(Types.typeNameFor(propertiesHost.getErasedType()))) {
return Optional.absent();
}
Map<String, ModelProperty> properties = newLinkedHashMap();
int index = 0;
for (com.mangofactory.swagger.models.property.ModelProperty each : properties(modelContext, propertiesHost)) {
properties.put(each.getName(), new ModelProperty(each.typeName(modelContext),
each.qualifiedTypeName(),
index,
each.isRequired(),
each.propertyDescription(),
each.allowableValues(),
itemModelRef(each.getType())
));
}
return Optional.of(new Model(typeName(propertiesHost),
typeName(propertiesHost),
simpleQualifiedTypeName(propertiesHost),
toScalaLinkedHashMap(properties),
modelDescription(propertiesHost), Option.apply(""),
Option.<String>empty(),
collectionAsScalaIterable(new ArrayList<String>()).toList()));
}
内容来源于网络,如有侵权,请联系作者删除!