This question is an extension of this question.
I have a class similar to the following.
class HighlightableStructure {
private final HighlightableStructure NEXT;
HighlightableStructure(HighlightableStructure next) {
NEXT = next;
}
}
where a HighlightableStructure
points to the next structure to highlight.
Sometimes, these HighlightableStructure
s loop around and refer to a previous HighlightableStructure
, but not the first in the chain. Something like h_1 -> h_2 ->h_3 -> ... -> h_n -> h_2, where h_i is an instance of HighlightableStructure
.
Is there anyway I could construct something like this without reflection or losing immutability?