1 package ru.bosony.model.cellscontents;
3 import java.util.HashSet;
6 import ru.bosony.model.io.TextRepresentable;
9 * @author indvdum (gotoindvdum[at]gmail[dot]com) <br>
13 public enum CellContent implements TextRepresentable {
15 ClosedLambdaLift("L"),
45 private CellContent trampolineTarget = null;
46 private static Set<CellContent> trampolines = new HashSet<CellContent>();
47 private static Set<CellContent> targets = new HashSet<CellContent>();
49 trampolines.add(TrampolineA);
50 trampolines.add(TrampolineB);
51 trampolines.add(TrampolineC);
52 trampolines.add(TrampolineD);
53 trampolines.add(TrampolineE);
54 trampolines.add(TrampolineF);
55 trampolines.add(TrampolineG);
56 trampolines.add(TrampolineH);
57 trampolines.add(TrampolineI);
69 private CellContent(String text) {
74 public String toText() {
78 public static CellContent fromText(String text) {
79 for (CellContent content : values()) {
80 if (text != null && text.equals(content.toText()))
86 public CellContent getTrampolineTarget() {
87 return trampolineTarget;
90 public void setTrampolineTarget(CellContent trampolineTarget) {
91 if (!trampolines.contains(this) || trampolineTarget != null && !targets.contains(trampolineTarget))
92 throw new RuntimeException("Only references from Trampolines to Targets allowed");
93 this.trampolineTarget = trampolineTarget;
96 public static Set<CellContent> getTrampolines() {
100 public static Set<CellContent> getTargets() {