23 lines
625 B
Java
23 lines
625 B
Java
package org.syndicate_lang.actors.example.example1;
|
|
|
|
import org.syndicate_lang.actors.Entity;
|
|
import org.syndicate_lang.actors.Turn;
|
|
|
|
public class ValueHolder<T> extends Entity {
|
|
private T value;
|
|
|
|
public ValueHolder(T initialValue) {
|
|
this.value = initialValue;
|
|
}
|
|
|
|
@Override
|
|
public void message_(Turn turn, Object body) {
|
|
if (body instanceof IValueHolder.Get op) {
|
|
turn.message_(op.k(), this.value);
|
|
} else if (body instanceof IValueHolder.Set) {
|
|
IValueHolder.Set<T> op = (IValueHolder.Set<T>) body;
|
|
this.value = op.newValue();
|
|
}
|
|
}
|
|
}
|