I have a requirement where value of one field in an object will be determined dynamically using a configurable table. For example, suppose I have the following table -

Pk | Reference_column

1 | TAB_REF.AMOUNT

where TAB_REF is a reference table and AMOUNT is one of the column of TAB_REF table.
If above value exists in the database, the amount in the application will be obtained from the TAB_REF.AMOUNT column.
My requirement is, for the above dataset I will have a class called TabRef and that class will have a method getAmount(). I have to identify the class and the method in my application using the above value.

My idea is to writing an API which will create the Class name with the substring before (.) and another API to generate the method with substring after (.). But I don't think this is a good idea. Is there any better idea to accomplish the requirement? Please suggest, thanks in advance.

Using a String to get access to a class sounds like you need to use a Map or reflection.
Using a String to create a call to a method sounds like you would need to use reflection.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.