Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface JavaProductAPI {
- public Set<IProduct> getProducts(String isin);
- }
- public class JavaProductAPIImpl implements JavaProductAPI {
- private Map<String, Set<ProductImpl>> productsByIsin;
- public Set<IProduct> getProducts() {
- Set<ProductImpl> s = productsByIsin.get(isin);
- return s == null
- ? Collections.<IProduct>emptySet()
- : Collections.<IProduct>unmodifiableSet(s);
- }
- }
- val productsByIsin: Map[String, scala.collection.Set[ProductImpl]] = ...
- def getProducts(isin: String): scala.collection.immutable.Set[IProduct] = {
- productsByIsin.get(isin) match {
- case Some(s) => scala.collection.immutable.Set(s toSeq :_*)
- case None => scala.collection.immutable.Set.empty
- }
- }
- val productsByIsin: Map[String, scala.collection.mutable.Set[ProductImpl]] = ...
- def getProducts(isin: String): scala.collection.Set[IProduct] = {
- productsByIsin.get(isin) match {
- case Some(s) => s readOnly
- case None => scala.collection.Set.empty
- }
- }
- import scala.collection._
- trait IProduct
- class ProductImpl extends IProduct
- val productsByIsin: immutable.Map[String, immutable.Set[ProductImpl]] =
- immutable.Map.empty
- def getProducts(isin: String): immutable.Set[IProduct] =
- productsByIsin.getOrElse(isin, immutable.Set.empty).asInstanceOf[immutable.Set[IProduct]]
Add Comment
Please, Sign In to add comment