com.g2forge.alexandria.java.nestedstate.FlagState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ax-java Show documentation
Show all versions of ax-java Show documentation
Standard Java library and the basis of the ${alexandria.name} project.
package com.g2forge.alexandria.java.nestedstate;
import com.g2forge.alexandria.java.close.ICloseable;
public class FlagState implements INestedState {
protected boolean inside;
protected void close(boolean expected, boolean previous) {
if (inside != expected) throw new IllegalStateException();
this.inside = previous;
}
@Override
public Boolean get() {
return inside;
}
@Override
public ICloseable open(Boolean value) {
final boolean previous = inside;
final boolean expected = this.inside |= value;
return () -> close(expected, previous);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy