
com.bigcustard.util.WatchableValue Maven / Gradle / Ivy
package com.bigcustard.util;
import com.google.common.base.Objects;
import java.util.function.Consumer;
public class WatchableValue extends Watchable {
private T value;
public WatchableValue(T value) {
this.value = value;
}
@Override
public WatchableValue watch(Consumer watcher) {
super.watch(watcher);
return this;
}
public void broadcast() {
broadcast(value);
}
public void set(T value) {
this.value = value;
broadcast();
}
public T get() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
WatchableValue> watchable = (WatchableValue>) o;
return Objects.equal(value, watchable.value);
}
@Override
public int hashCode() {
return Objects.hashCode(value);
}
@Override
public String toString() {
return "WatchableValue{value=" + value + '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy