Created
November 30, 2017 05:48
-
-
Save Satomaru/d2b479072c506e7b2768d792d051fb78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Supplier; | |
public enum CircularReference { | |
P1(() -> Child.C1), | |
P2(() -> Child.C2); | |
public enum Child { | |
C1(P1), | |
C2(P2); | |
private final CircularReference parent; | |
private Child(CircularReference parent) { | |
this.parent = parent; | |
} | |
public CircularReference getParent() { | |
return parent; | |
} | |
} | |
private final Supplier<Child> supplier; | |
private CircularReference(Supplier<Child> supplier) { | |
this.supplier = supplier; | |
} | |
public Child getChild() { | |
return supplier.get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment