A
Andreas Leitgeb
I've got an enum that contains Things that come in pairs.
I'd like each Thing to have a *final* reference to
it's mate, that in half of the cases appears later
in the list of Thing-instances.
e.g.:
enum Thing {
T1, T2;
final Thing mate;
}
What could I do, to make T2 "final"ly the mate of T1
and vice versa ?
I know some alternatives, myself, like just making the
reference non-final (and initialize it in the enum's
static {...} block) or defining an abstract method in
the enum like "abstract Thing getMate();" and implement
it for each instance to return its mate...
Please only followup, if you know a trick for final fields,
or if you know that it is strictly impossible that way.
I'd like each Thing to have a *final* reference to
it's mate, that in half of the cases appears later
in the list of Thing-instances.
e.g.:
enum Thing {
T1, T2;
final Thing mate;
}
What could I do, to make T2 "final"ly the mate of T1
and vice versa ?
I know some alternatives, myself, like just making the
reference non-final (and initialize it in the enum's
static {...} block) or defining an abstract method in
the enum like "abstract Thing getMate();" and implement
it for each instance to return its mate...
Please only followup, if you know a trick for final fields,
or if you know that it is strictly impossible that way.