My personal opinion on this is that it would be better to depend on a library that provides this functionality (I think guava has some classes to help with this, for example), rather than taking on the maintenance burden of putting into Spark. However, if you're really trying to limit the dependencies, then this can be worth it. I'll let you make that decision. :)