org.checkerframework.dataflow.cfg.builder.LabelCell Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java's type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.dataflow.cfg.builder;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.javacutil.BugInCF;
/** Storage cell for a single Label, with tracking whether it was accessed. */
/*package-private*/ class LabelCell {
/** The label. If it is null, then it will be lazily set if {@link #accessLabel} is called. */
private @MonotonicNonNull Label label;
/** True if the label has been accessed. */
private boolean accessed;
/** Create a LabelCell with no label; the label will be lazily created if needed. */
protected LabelCell() {
this.accessed = false;
}
/**
* Create a LabelCell with the given label.
*
* @param label the label
*/
protected LabelCell(Label label) {
assert label != null;
this.label = label;
this.accessed = false;
}
public Label accessLabel() {
if (label == null) {
label = new Label();
}
accessed = true;
return label;
}
public Label peekLabel() {
if (label == null) {
throw new BugInCF("called peekLabel prematurely");
}
return label;
}
public boolean wasAccessed() {
return accessed;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy