@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(); }
/** * 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())); } }
/** * 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); }
private static scala.collection.Iterable toIter(Object array) { return JavaConversions.collectionAsScalaIterable((Collection) array); }
@Override public AllowableListValues apply(ApiModelProperty annotation) { List<String> allowableValues = Splitter.on(',').omitEmptyStrings().splitToList(nullToEmpty(annotation.allowableValues())); return new AllowableListValues(JavaConversions.collectionAsScalaIterable(allowableValues).toList(), "LIST"); } };
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; }
JavaConversions.collectionAsScalaIterable(specifiedTopics).toSeq() : zkUtils.getAllTopics();
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; }
@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())); }