isComputed() supported for lazy values

This commit is contained in:
Andrey Breslav
2013-10-02 12:51:45 +04:00
parent 7dfe1f963d
commit 344a57f2d5
4 changed files with 13 additions and 1 deletions
@@ -155,6 +155,11 @@ public class LockBasedStorageManager implements StorageManager {
this.computable = computable; this.computable = computable;
} }
@Override
public boolean isComputed() {
return value != NOT_COMPUTED && value != COMPUTING;
}
@Override @Override
public T compute() { public T compute() {
Object _value = value; Object _value = value;
@@ -23,4 +23,7 @@ public interface NotNullLazyValue<T> extends Computable<T> {
@Override @Override
@NotNull @NotNull
T compute(); T compute();
// Needed for proper toString() behaviors
boolean isComputed();
} }
@@ -23,4 +23,7 @@ public interface NullableLazyValue<T> extends Computable<T> {
@Override @Override
@Nullable @Nullable
T compute(); T compute();
// Needed for proper toString() behaviors
boolean isComputed();
} }
@@ -30,8 +30,9 @@ public abstract class NullableLazyValueImpl<T> implements NullableLazyValue<T> {
@Nullable @Nullable
private Object value = State.NOT_COMPUTED; private Object value = State.NOT_COMPUTED;
@Override
public boolean isComputed() { public boolean isComputed() {
return value != State.NOT_COMPUTED; return value != State.NOT_COMPUTED && value != State.COMPUTING;
} }
@Override @Override