/** * Manually converting to scala set to avoid binary compatibility issues between scala versions when using JavaConverters */ @SuppressWarnings("unchecked") static <T> scala.collection.immutable.Set<T> toImmutableScalaSet(Set<T> set) { ListBuffer<T> buffer = new ListBuffer<>(); set.forEach((e) -> buffer.$plus$eq(e)); return Set$.<T> MODULE$.apply(buffer); }
/** * Converts a {@link java.util.Set} to an immutable Scala Set. * * See scala.collection.JavaConverters.asScalaSet if you do * not need the returned Set to be immutable. * * @return an empty Set if the input is null. */ @SuppressWarnings("unchecked") public static <E> scala.collection.immutable.Set<E> asImmutableSet( java.util.Set<E> jSet ) { if (jSet == null) { return scala.collection.immutable.Set$.MODULE$.<E>empty(); } else { //TODO: After dropping support for 2.11.x, replace with //JavaConverters.asScalaSet(jSet).toSet return JavaConverters.asScalaSetConverter(jSet).asScala().toSet(); } }
/** * Converts a {@link java.util.Set} to an immutable Scala Set. * * See scala.collection.JavaConversions.asScalaSet if you do * not need the returned Set to be immutable. * * @return an empty Set if the input is null. */ @SuppressWarnings("unchecked") public static <E> scala.collection.immutable.Set<E> asImmutableSet( java.util.Set<E> jSet ) { if (jSet == null) { return scala.collection.immutable.Set$.MODULE$.<E>empty(); } else { return asScalaSet(jSet).toSet(); } }
/** * Converts a {@link java.util.Set} to an immutable Scala Set. * * See scala.collection.JavaConverters.asScalaSet if you do * not need the returned Set to be immutable. * * @return an empty Set if the input is null. */ @SuppressWarnings("unchecked") public static <E> scala.collection.immutable.Set<E> asImmutableSet( java.util.Set<E> jSet ) { if (jSet == null) { return scala.collection.immutable.Set$.MODULE$.<E>empty(); } else { //TODO: After dropping support for 2.11.x, replace with //JavaConverters.asScalaSet(jSet).toSet return JavaConverters.asScalaSetConverter(jSet).asScala().toSet(); } }