Sunday, September 18, 2011

Scala map implicit conversion into Java Properties

As it looks that there's no implicit conversion of a Scala Map (of Strings) into a Java Properties even in the latest Scala release, let's define one.
  implicit def map2Properties(map:Map[String,String]):java.util.Properties = {
    val props = new java.util.Properties()
    map foreach { case (key,value) => props.put(key, value)}
    props
  }


Or even in a one line fashion, using folding :
  implicit def map2Properties(map:Map[String,String]):java.util.Properties = {
    (new java.util.Properties /: map) {case (props, (k,v)) => props.put(k,v); props}
  }


CONTEXT : Linux Gentoo / Scala 2.9.1 / Java 1.6.0_26

44 comments:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

    ReplyDelete
  2. Really very informative post you shared here. Keep sharing this type of informative blog. If anyone wants to become a Java professional learn Java Training in Bangalore. Nowadays Java has tons of job opportunities for all professionals.

    ReplyDelete
  3. Good and nice information... thanks for sharing your views and ideas. keep rocks and updating..Selenium Training Institute in Chennai | Selenium Training Institute in Velachery


    ReplyDelete
  4. Excellent Blog with informative content. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog. Best Web Design Training in Chennai | Angular JS Training in Chennai | Best CMS Training in Chennai

    ReplyDelete
  5. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java Training in Bangalore

    ReplyDelete
  6. Thanks for your marvelous posting! It is very useful and good. Come on. I want to introduce the best aso services for you, I try it and I feel it is so good to rank app to top in app store search results, have you ever heard it?

    ReplyDelete
  7. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    java training in bangalore
    java training in bangalore


    ReplyDelete
  8. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete
  9. And after 20 years, I'm doing it again - helping Australians who lost a lot of money, to get out of the United States and will still be able to keep the remaining capital that they have invested. scott

    ReplyDelete
  10. Ciitnoida provides Core and java training institute in

    noida
    . We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-

    oriented, java training in noida , class-based build

    of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an

    all-time high not just in India but foreign countries too.

    By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13

    years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best

    Java training in Noida.

    java training institute in noida
    java training in noida

    ReplyDelete
  11. Best Summer Internship In Noida

    These technologies prepare individuals for fields like software programming, technical support, graphic design, software testing, business analytics. Embedded Systems, Industrial Automation Training and more. Candidates go through a series of comprehensive practical sessions where they work on live problems and implement solutions on real-time basis.
    It has a dedicated placement cell which provides 100% placement assistance to students. The benefits that a student gets out of summer training are innumerable. CIITN,Best Summer training Center for B.Tech/CS/CSE/IT/ BCA/MCA/ B.E /M.tech / B.sc/ M.sc/ Engineering Student has already accomplished itself successfully in the field of Training and Development after setting milestones and bringing smiles to the faces of more than 1 Lakh students. CIITN was incorporated in the year 2002 and over the years CIITN has grown remarkably into the greatest training giant of Northern India.
    There is no looking back to technology! Those passionate for it need not worry about the professional prospects it offers. Courses and trainings in the field of Computer Science and Applications open a wide array of choices for individuals. All you need to do it prepare yourself right!

    Summer Internship Course In Noida

    Summer Internship Training In Noida

    ReplyDelete
  12. Awesome article.The information I have been searching precisely. It helped me a lot, thanks. Keep coming with more such informative article. Would love to follow them.
    sap abap programming training

    ReplyDelete

  13. Thanks for sharing this informative article..!!
    Keep posting waiting for next post
    iOS Training in Bangalore
    Java Training in Bangalore

    ReplyDelete
  14. It is really great work and the way in which you are sharing the knowledge is excellent. Thanks for your informative article
    RPA Training Course in Chennai | RPA Training Course in Velachery

    ReplyDelete
  15. Great post! Thanks for sharing with us, Its really gives lot of useful information. Regards,

    Angularjs Training in Chennai

    ReplyDelete
  16. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    No.1 Microsoft Azure Training Institute in Chennai | No.1 Microsoft Azure Training Institute in Velachery

    ReplyDelete
  17. The provided information’s are very useful to me. It’s a wonderful site for learning.Thank you for sharing this wonderful blog.
    Robotics Project Center Training in Chennai | Best Robotics Project Course in Tambaram

    ReplyDelete
  18. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    Certified Ethical Hacking Training in Chennai | Certified Ethical Hacking Training in Velachery

    ReplyDelete
  19. Nice post. This post is very helpful. Thank you so much for sharing this post.
    CLOUD COMPUTING Classes in Chennai | CLOUD COMPUTING Courses in Velachery

    ReplyDelete
  20. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Selenium Testing Course in Chennai | Selenium Testing Course in Velachery

    ReplyDelete
  21. I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
    No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Velachery | No.1 Blue Prism Training Institute in Kanchipuram

    ReplyDelete
  22. Nice. You have clearly explained about it ...It’s very useful for me to know about new things. Keep on blogging..
    Automation Anywhere Training with Placement in Chennai | Automation Anywhere Training with Placement in Tambaram

    ReplyDelete