/** * Converts a Java Collection to a Scala Seq. * * @param javaCollection the java collection * @param <A> the type of Seq element * @return the scala Seq. */ public static <A> scala.collection.immutable.Seq<A> asScala(Collection<A> javaCollection) { return scala.collection.JavaConverters.collectionAsScalaIterableConverter(javaCollection).asScala().toList(); }
/** * Converts a Java Collection to a Scala Seq. * * @param javaCollection the java collection * @param <A> the type of Seq element * @return the scala Seq. */ public static <A> scala.collection.immutable.Seq<A> asScala(Collection<A> javaCollection) { return scala.collection.JavaConverters.collectionAsScalaIterableConverter(javaCollection).asScala().toList(); }
/** * Converts a Java Collection to a Scala Seq. * * @param javaCollection the java collection * @param <A> the type of Seq element * @return the scala Seq. */ public static <A> scala.collection.immutable.Seq<A> asScala(Collection<A> javaCollection) { return scala.collection.JavaConverters.collectionAsScalaIterableConverter(javaCollection).asScala().toList(); }
/** * Converts a Java Collection to a Scala Seq. */ public static <A> scala.collection.immutable.Seq<A> asScala(Collection<A> javaCollection) { return scala.collection.JavaConverters.collectionAsScalaIterableConverter(javaCollection).asScala().toList(); }
@Override public final Seq<play.api.inject.Binding<?>> bindings(final play.api.Environment environment, final play.api.Configuration configuration) { List<play.api.inject.Binding<?>> list = bindings(environment.asJava(), configuration.underlying()).stream() .map(Binding::asScala) .collect(Collectors.toList()); return JavaConverters.collectionAsScalaIterableConverter(list).asScala().toList(); }
@Override public final Seq<play.api.inject.Binding<?>> bindings(final play.api.Environment environment, final play.api.Configuration configuration) { List<play.api.inject.Binding<?>> list = bindings(environment.asJava(), configuration.underlying()).stream() .map(Binding::asScala) .collect(Collectors.toList()); return JavaConverters.collectionAsScalaIterableConverter(list).asScala().toList(); }
@Override public final Seq<play.api.inject.Binding<?>> bindings(final play.api.Environment environment, final play.api.Configuration configuration) { List<play.api.inject.Binding<?>> list = bindings(environment.asJava(), configuration.underlying()).stream() .map(Binding::asScala) .collect(Collectors.toList()); return JavaConverters.collectionAsScalaIterableConverter(list).asScala().toList(); }
@Override public AllowableListValues apply(ApiModelProperty annotation) { List<String> allowableValues = Splitter.on(',').omitEmptyStrings().splitToList(nullToEmpty(annotation.allowableValues())); return new AllowableListValues(JavaConversions.collectionAsScalaIterable(allowableValues).toList(), "LIST"); } };
/** * Converts a Java Collection to a Scala Seq. */ public static <A> scala.collection.immutable.Seq<A> asScala(Collection<A> javaCollection) { return scala.collection.JavaConverters.collectionAsScalaIterableConverter(javaCollection).asScala().toList(); }
public static Object scalaIterableCheck(Object array, Schema schema) { Class collectionClass = ScalaSafeReflectData.getClassProp(schema, ScalaSafeReflectData.CLASS_PROP); if (collectionClass != null) { if (scala.collection.Iterable.class.isAssignableFrom(collectionClass)) { scala.collection.Iterable it = toIter(array); if (scala.collection.immutable.List.class.isAssignableFrom(collectionClass)) { return it.toList(); } if (scala.collection.mutable.Buffer.class.isAssignableFrom(collectionClass)) { return it.toBuffer(); } if (scala.collection.immutable.Set.class.isAssignableFrom(collectionClass)) { return it.toSet(); } return it; } } return array; }
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; }
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; }
List<KApply> topologicalSorted = mutable(TopologicalSort.tsort(immutable(edges)).toList()); return state.stream().sorted((k1, k2) -> (topologicalSorted.indexOf(k1) - topologicalSorted.indexOf(k2)));
List<KApply> topologicalSorted = mutable(TopologicalSort.tsort(immutable(edges)).toList()); return state.stream().sorted((k1, k2) -> (topologicalSorted.indexOf(k1) - topologicalSorted.indexOf(k2)));
@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())); }