Denis Rosca
Denis Rosca

Reputation: 3469

Typesafe config load from java.util.prefs.Preferences

I'm trying to figure out how to properly instantiate a Config instance using a java.util.prefs.Preferences object.

The API exposes a ConfigFactory.load() method that takes a java.util.Properties parameter, but for the life of me I can't figure out how to do the Preferences to Properties conversion.

Do you guys have any hints?

P.S. I get the preferences object as a parameter from an external context and modifying it to something more convenient is not really an option.

Upvotes: 1

Views: 158

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170733

There seems to be no direct way to do it. Implementing ConfigParseable to add new kinds of file formats/APIs is very explicitly not supported.

The easiest thing I can think is to write your own method for converting Preferences to Properties recursively, using childrenNames() and keys().

Upvotes: 1

Related Questions