• Post Reply Bookmark Topic Watch Topic
  • New Topic

Properties constructor that takes a Properties object: Confusion!  RSS feed

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok, so what's the possible rationale behind this behaviour? Why would Properties objects extend Hashtable, and then have a separate 'defaults' repository, which doesn't show up in toString() or isEmpty()? I can easily get the behaviour I think is ideal by simply replacing the constructor that accepts a Properties object, with a call to .putAll(). But I would have thought that was how it should have worked!

The only advantage of the constructor's behaviour, is if I want to call isEmpty() to determine if any of my defaults were overriden.

But it's quite confusing to have isEmpty() return true, but getProperty("some default") return a value!!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All I can say is, I hear you, pal. Properties is one of the many badly designed classes in the early Java API. There are more of them than there should be, that's for sure.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!