Re: Type of a generic class?
On 8/2/2012 4:27 PM, Donkey Hottie wrote:
It is indeed kind of spooky and strange idea, after all what is so wrong
about simple
String value = SystemProperties.getString("ParamName") ;
It is OK, but I'm kind of toying with idea of strong typing of System
Parameters: A Date can not be stored as Long or Double etc..
To do something like this, I'd arrange some implementation for the
parameter:
class Parameter {
public void processParam( String param ) {
double d = Double.parse( param ); // or whatever...
...
}
}
And then use a Map as Lew suggests or some other method of binding the
Parameter class to the string "ParamName".
(You could, for example use Class.forName():
Parameter proc = Class.forName(
"my.project.parameter."+"ParamName").newInstance();
or you could use annotations:
@Parameter("ParamName")
class Parameter {...
or any other crazy thing you like. It would probably be better than
what you have now.)
The back end of the system parameters is simply
CREATE TABLE SystemParameters
(
name varchar(64) not null primary_key,
value varchar(512)
) ;
I've written this table definition. In fact it was 23 odd years ago, as
in intern while still in college. I don't know if it's good or bad
practice, but it seems a common idea.