I can understand using properties for messages and international settings but I feel there has to be a better way to get specific parameters of a program like background color, resolution, floating point numbers, etc.
Every time I load a set of properties I have to have a wrapper class to convert all those into something meaningful to my program. Say I want to load a color, I have to read the color as a string and then convert it to a color in my program. Everything in a property is a string. So numbers have to get converted too.
I feel like there should be some sortof of library that can detect(or maybe it’s specified in the file) what it is and you would automatically get the correct data type when you load it in.
Is there anything like this? Thanks.
As KitsuneYMG mentioned, you can use an XML deserializer to more easily handle the unmarshalling of configurable, typed values; XStream is an excellent library to simplify the object field mapping process. Also consider the YAML and JSON serialization formats as alternatives to XML, they are more concise and potentially easier to manage and both have fine Java bindings.
Moreover, by accessing these configurable objects via the Factory pattern you can have better control for loading special cases (such as automated tests) as well as XML documents from the filesystem or classloader resources.