I know if I were in PHP I would be able to create an object as following:
// class Name
$var = "Name";
$my_name = new $var("John", "Doe");
Now, I wanted to adopt similar approach in Java. I have a file which I need to parse and produce objects depending on the line read from the file. For example:
2235:org.powertac.common.TariffSpecification::8::addRate::9
2235:org.powertac.common.Tariff::8::new::8
2235:org.powertac.common.TariffSpecification::10::new::1::PRODUCTION
2236:org.powertac.common.Rate::11::new
2236:org.powertac.common.Rate::11::withValue::0.015
2236:org.powertac.common.Rate::11::setTariffId::10
2236:org.powertac.common.TariffSpecification::10::addRate::11
2236:org.powertac.common.Tariff::10::new::10
2247:org.powertac.common.RandomSeed::12::init::DistributionUtilityService::0::model::-7651755067434358
2257:org.powertac.genco.Genco::13::new::nsp1a::true::true
2258:org.powertac.genco.Genco::13::new::nsp1a
2258:org.powertac.genco.Genco::15::new::nsp1b::true::true
then I should create an object of the type Rate, (new), with default values.
Therefore, parsing that line would yield me:
"org.powertac.common.Rate"(String) and I wanted to create a org.powertac.common.Rate object. How could I do it? I know it's a lazy evaluation ... how can I create something similar in Java?