Plan for tomorrow morning
Meeting next to the Rektorát VŠB tram stop at 10:00 (see the map here: https://en.mapy.cz/s/3mp2s)
Taking tram no. 7 from there to the Vřesinská tram stop at 10:08
Taking tram no. 5 from there at 10:16
Arriving at Budišovice, Zátiší at 10:35
Strolling around fields, meadows and forests for roughly 1 hour
A cup of hot beverage in one of the local pubs
Taking a bus from there back to Ostrava at 12:22
Arriving at the Pustkovecká bus stop at 12:44, going straight to Lev/U Jarošů for lunch (others can meet us there)
/**
* A variable of type {@code T}.
* Accessible via {@link #get()} / {@link #set(Object)}.
* Listeners
*
* @author Tobias Pietzsch
*/
public class ListenableVar< T, L >
{
private final AtomicReference< T > ref;
private final Listeners.List< L > listeners;
private final BiConsumer< L, T > notify;
private final boolean notifyWhenSet;
public ListenableVar( final T value, final Consumer< L > notify )
{
this( value, notify, false );
}
public ListenableVar( final T value, final BiConsumer< L, T > notify )
{
this( value, notify, false );
}
public ListenableVar( final T value, final Consumer< L > notify, final boolean notifyWhenSet )
{
this( value, ( l, t ) -> notify.accept( l ), notifyWhenSet );
}
public ListenableVar( final T value, final BiConsumer< L, T > notify, final boolean notifyWhenSet )
{
this.ref = new AtomicReference<>( value );
this.notify = notify;
this.notifyWhenSet = notifyWhenSet;
this.listeners = new Listeners.SynchronizedList<>();
}
public void set( final T value )
{
final T previous = this.ref.getAndSet( value );
if ( notifyWhenSet || !previous.equals( value ) )
listeners.list.forEach( l -> notify.accept( l, value ) );
}
public T get()
{
return ref.get();
}
public Listeners< L > listeners()
{
return listeners;
}
interface ChangeListener
{
void changed();
}
interface ValueListener< T >
{
void valueChanged( T value );
}
public static void main( String[] args )
{
{
ListenableVar< Integer, ChangeListener > var = new ListenableVar<>( 1, ChangeListener::changed );
var.listeners().add( () -> System.out.println( "value changed" ) );
var.set( 10 );
System.out.println( "var = " + var.get() );
}
{
ListenableVar< Integer, ValueListener< Integer > > var = new ListenableVar<>( 1, ValueListener::valueChanged );
var.listeners().add( v -> System.out.println( "value changed to " + v ) );
var.set( 10 );
System.out.println( "var = " + var.get() );
}
}
}