M
Mikhail Teterin
Hello!
I would like to be able to initialize fields of an enum with /methods/ (of
another Class).
Here is the (non-working) example:
import java.util.*;
import java.sql.*;
public enum Field {
FIELD1 (ResultSet.getString),
FIELD2 (ResultSet.getDouble),
...
FIELDN (ResultSet.getTimestamp);
private java.lang.reflect.Method extract;
}
the idea is to be able to get all fields from a given ResultSet by going
through the list of Fields and extracting the column from the ResultSet.
Something like:
public void print(ResultSet rs)
{
for (Field f : Field.values())
System.out.println(f + ":\t" + rs.f.extract(f));
}
Does the above stand a chance of being turned into a real Java code?
Thanks for ideas!
-mi
I would like to be able to initialize fields of an enum with /methods/ (of
another Class).
Here is the (non-working) example:
import java.util.*;
import java.sql.*;
public enum Field {
FIELD1 (ResultSet.getString),
FIELD2 (ResultSet.getDouble),
...
FIELDN (ResultSet.getTimestamp);
private java.lang.reflect.Method extract;
}
the idea is to be able to get all fields from a given ResultSet by going
through the list of Fields and extracting the column from the ResultSet.
Something like:
public void print(ResultSet rs)
{
for (Field f : Field.values())
System.out.println(f + ":\t" + rs.f.extract(f));
}
Does the above stand a chance of being turned into a real Java code?
Thanks for ideas!
-mi